Am using master page in my asp.net application, and I want to reset the fields when I click the Cancel button.
I can achieve this by adding the onClientClick event as
OnClientClick="this.form.reset();return false;"
its working but, I already used this function for showing the confirm cancel popup like,
OnClientClick="return confirmCancel()"
this confirmCancel() is written in the js file called Custom.js and its under the folder called Script.
I need to show this confirmCancel() pop up and if I give ok it should clear the form, how can I achieve this, can anyone help me here…
this is the confirmCancel() method
function confirmCancel() {
var c = confirm("Confirm Cancel?");
if (c) {
return true;
}
else {
return false;
}
}
You can make
I make a simple test here: http://jsfiddle.net/LY3dd/4/
What I do here, by adding the
&&the javascript first run theconfirmand if this is return true, then is run the second part that is the reset. If theconfirmreturn false, is stop there (and not clear the form).