Blog > detail

Just my tiny mind

Confirmation in Javascript

26-2-2012 Admin General 2 Comments

Confirmation in Javascript

Confirmation in Javascript is very useful for validating something important in your web. Let say, in admin page for managing member. And you accidentally press member delete button. If your site dont have confirmation, you already lost a member. Therefore Confirmation in Javascript is important to your site that manage important information.


The script that you have to write in order to make Confirmation in Javascript is indeed simple. The main script is:


var agree = confirm ("Are you sure?")

if (agree){

//code when you agree

}else{

//code when you disagree

}


On the other hand, you can make multiple level of Confirmation in Javascript such as:


var agree = confirm ("Are you sure?")

if (agree){

var agree2 = confirm ("Are you realy sure?")

if (agree2){

var agree3 = confirm ("Are you absolutely sure?")

if (agree3){

//code when you agree

}

}

}


For the above example, there are 3 Confirmation in Javascript appear, before it execute the code part when you agree. You can also modify the code so that you need to answer 'yes' then 'no' then 'yes' before it execute the code part when you agree, see bellow.


var agree = confirm ("Are you sure?")

if (agree){

var agree2 = confirm ("Cancle this action?")

if (agree2){

}else{

var agree3 = confirm ("Are you absolutely sure?")

if (agree3){

//code when you agree

}

}

}


By implementing multilple level of Confirmation in Javascript, you can protect your data more safe from accidentally action.


 

Confirmation in Javascript Confirmation in Javascript Confirmation in Javascript

Confirmation in Javascript Confirmation in Javascript Confirmation in Javascript

Confirmation in Javascript

word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word word

Confirmation in Javascript

Confirmation in Javascript

Confirmation in Javascript