I’ve got a form with a number of fields and a few checkboxes. When the user clicks save, if a certain checkbox isn’t checked, they’re prompted with a ‘Confirm’ dialog box asking if they still want to save the form. If they click okay, the button should fire it’s event handler normally, but if they click cancel, nothing should happen.
function checkVerification(checkBox)
{
if (!document.getElementById(checkBox).checked)
{
confirm('Worksheet has not been verified. Save anyway?');
}
}
As of right now, the Save button’s event handler fires regardless of the user’s choice. Any advice would be greatly appreciated.
You need to tie the return value of the confirm dialog to the
OnClientClickof the button, like this:In this case, if user clicks Yes the page will perform a postback. If the user clicks No the postback will be aborted.
After looking at your comment, try this:
And in your JavaScript function: