Confirmation in Javascript

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.

http://septiadi.com/2011/04/07/confirmation-in-javascript/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: