Articles → JAVASCRIPT → Alerts In Javascript

Alerts In Javascript


Types Of Alerts

  1. Alert box
  2. Confirm box
  3. Prompt box

Alert Box

alert("Hi,this message is for information purpose.");  

Try It

Picture showing the alert box in JavaScript

Confirm Box

if(confirm("Are you sure you want to save your personal information?") == true) {
        // Do Something
        // Do Something else

Try It

Picture showing the confirm box in JavaScript

Prompt Box

var age = prompt("Please enter your age", "18");
 if (parseInt(age) >= 18) {
  alert("You are eligible to vote");
 } else {
  alert("Sorry,you can't vote");

Try It

Picture showing the prompt box in JavaScript

Posted By  -  Karan Gupta
Posted On  -  Tuesday, March 22, 2011


Your Email Id  
Query/FeedbackCharacters remaining 250