Press "Enter" to skip to content

Message Box Examples in CSS

Last updated on October 5, 2019

Message box:

It is a popup which is meant for displaying the output or taking the input from the user.

There are three different types of message boxes available those are.

  • Alert.
  • Confirm.
  • Prompt.

Alert:

This is a message box which is meant for displaying a message with ok button.

Program :

<html>

     <head>

                     <script type=”text/javascript”>

                                     function display ()

                                                 {

                                                   alert(“Hello Welcome”);

                                                  }

                                </script>

                </head>

                <body>

                     <input type=”button” value=”First button” onclick=”display()”/>

                </body>

</html>

Confirm:

It is a message box which is meant for displaying a message with ok cancel button.

Program :

<html>

     <head>

                     <script type=”text/javascript”>

                                     function display ()

                                                 {

                                                   confirm(“do you want addition ?.”);

                                                  }

                                </script>

                </head>

                <body>

                     <input type=”button” value=”First button” onclick=”display()”/>

                </body>

</html>

Prompt:

  • It is a message box which is meant for displaying a message with a text field and ok cancel button for taking input as well as cancelling input from the user.
  • It will take 2 parameters
  • The message to be displayed on the message box.
  • The default value which needs to be displayed in the text field. If user did not enter any value.

Program :

<html>

     <head>

                     <script type=”text/javascript”>

                                     function display ()

                                                 {

                                                   prompt(“enter A value”,”0″);

                                                  }

                                </script>

                </head>

                <body>

                     <input type=”button” value=”First button” onclick=”display()”/>

                </body>

</html>

Be First to Comment

    Leave a Reply

    Your email address will not be published. Required fields are marked *