You are here: Home » JavaScript » JavaScript Dialog Boxes

JavaScript Dialog Boxes

34 Flares 34 Flares ×

There are three JavaScript dialog boxes.
1. Alert Dialog Box.
2. Confirmation Dialog Box.
3. Prompt Dialog Box.

Alert Dialog Box
When we have to show warning meassage, we will use Alert Dialog Box, Suppose in form validation, User Name is mandatory field and user didn’t filled it, then we can show error message in Alert Dialog Box.

<head>
<script type="text/javascript">
   alert("Your Message");
</script>
</head>

Confirmation Dialog Box
When user have to choose one option out of two.It display a dialog box with two button ok and cancel

<head>
<script type="text/javascript">

   var newvar = confirm("Do you want to delete it ?");
   if( newvar == true ){
       return true;
   }else{
       return false;
   }
</script>
</head>

If User click on OK then go to next step, if click on Cancel no action will perform.

Prompt Dialog Box
When you have to get user input through a text box pop-up. You have to fill the field and click on OK

<head>
<script type="text/javascript">
  var newvar = prompt("Enter your name : ", "your name here");
</script>
</head>

About Abhishek Sinha

I am Abhishek and I love to code on PHP.

Leave a Reply

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

*

Scroll To Top
34 Flares Twitter 5 Facebook 4 Google+ 3 StumbleUpon 18 Pin It Share 1 LinkedIn 3 34 Flares ×