Sunday, 19 October 2014

Dialog Boxes in JavaScript(Alert, Prompt, Confirm)

Alert Dialog Box:
Alert dialog box is used to give alert on validation or other condition.
<head>
<script type="text/javascript">
<!--
   alert("Please enter value");
//-->
</script>
</head>
 
Confirm Dialog box:
This box is used to confirm for any condition 
<head>
<script type="text/javascript">
<!--
   var result= confirm("Are you sure to delete?");
   if( result== true ){
      alert("User wants to delete!");
   return true;
   }else{
      alert("User does not want to delete!");
   return false;
   }
//-->
</script>
</head>
Prompt Dialog Box:
This prompt dialog box is used to get user input on text box.
<head>
<script type="text/javascript">
<!--
   var result= prompt("please enter your name : ", "enter your name here");
   alert("You have entered : " +  result);
//-->
</script>
</head>  
 

No comments:

Post a Comment