Confirmation dialog box

Code Title: Confirmation dialog box
Language: Javascript

Description:

I am calling confirmForm() function from a button with an onClick, but
you can call it from the onSubmit handler when you send a form. If
they click ok, it returns true, and the form is submitted, if they
click cancel it returns false, and the form submit is cancelled.

Remember you must use return before your function call:
return confirmForm()

Added: 11/07/2008
Profile: Anil Gupta
User Name: anil

Recent Entries by Author:
Coming Soon!

Note: Please, always give credit to author for his/her work, if used in production environment.

Code

Javascript:
<script>
function confirmForm()
{
if (confirm('You cannot undo this operation. Are you sure you want
to delete this item? (Click \'OK\' to continue.'))
{
return true;
}
return false;
}
</script>

Form Section:
<input type="submit" name="SaveForm" onClick="return confirmForm()" value="Submit" >