Thursday, October 27, 2011

How to confirm before submitting a form with popup box

This will come in handy if you want to confirm before deletion. Modify your submit button to this:


<input type="Submit" name="Delete" value="Delete"
onClick="return confirmSubmit()">

The important part here is the onClick attribute.
And then add this somewhere on your page on top of the form:


<script LANGUAGE="JavaScript">
<!--
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to continue?");
if (agree)
 return true ;
else
 return false ;
}
// -->
</script>

That should do the trick :)

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
Web Design & Marketing - Click and get an instant quote on your project