Quantcast
Channel: Web Forms
Viewing all articles
Browse latest Browse all 23244

reset form and clear validator control messages

$
0
0

I have a bunch of validator controls on a form, required, custom, regular expression.

sample 

<asp:RequiredFieldValidator ID="otherTrainReq" runat="server" ControlToValidate="otherTrain"
SetFocusOnError="true" ErrorMessage="any training is required" CssClass="errorMsg"
Display="dynamic" /><br />

I am trying to get a 'reset' button to both do the standard clearing form to all defaults and clear all validator messages and validator default properties, ie, same as when page first loaded.

I have tried to clear them with a reset (<input type="reset" onclick="clearVals(event, this);" value="Reset" runat="server"/>

function clearVals(e, el) {

alert("test if function gets fired");
e.preventDefault();
el.form.reset();
for (i = 0; i < Page_Validators.length; i++) {
Page_Validators[i].style.display = 'none';
}
}

actually have tried a number of different javascript functions along these lines but.................

after putting the onclick= parm into the reset button, the reset function of setting form back to default does not work and  thejavascript function get fired, ie, i get the message box but the validator messages do not get cleared, so this is striking out for both of its intended functions??  has anybody actually been able to get both functions working from the reset ??


Viewing all articles
Browse latest Browse all 23244

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>