Note that there are some explanatory texts on larger screens.

plurals
  1. POMultipe validation control on single textbox
    text
    copied!<p>I have following code snippet in asp.net In which I am validating a Textbox.I have added two validation control in which first validate the format of date and second validates the future data.</p> <p>Now the problem is both validations fire at the same time. I want that first it's check that date is valid or not then I want to fire rangevalidator.</p> <pre><code> &lt;asp:TextBox Enabled="True" runat="server" size="8" MaxLength="10" meta:resourcekey="txtTravelerDOBResource2"&gt;mm/dd/yyyy&lt;/asp:TextBox&gt; &lt;asp:RangeValidator ID="rangeValidator" ControlToValidate="txtTravelerDOB" MaximumValue="09/25/2013" MinimumValue="1/1/2012" Type="Date" ErrorMessage="Future Date Not allowed" runat="server"&gt;&lt;/asp:RangeValidator&gt; &lt;asp:RegularExpressionValidator Enabled="True" ID="rgxDOB" runat="server" ControlToValidate="txtTravelerDOB" Display="Dynamic" ErrorMessage="Date is not valid" ValidationExpression="^(((0?[13578]|1[02])[\/](0?[1-9]|[12]\d|3[01])[\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[13456789]|1[012])[\/](0?[1-9]|[12]\d|30)[\/]((1[6-9]|[2-9]\d)?\d{2}))|(0?2[\/](0?[1-9]|1\d|2[0-8])[\/]((1[6-9]|[2-9]\d)?\d{2}))|(0?2[\/]29[\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))$" &gt;&lt;/asp:RegularExpressionValidator&gt; </code></pre> <p>I tried to enable disable the validation control using javascript as below.</p> <pre><code>function isGoodDate(){ var value=$("#ctl09_ctl00_ctl00_ctl00_rptTravelers_ctl01_txtTravelerDOB").val(); var v=$("#ctl09_ctl00_ctl00_ctl00_rptTravelers_ctl02_txtTravelerDOB").val(); var reGoodDate = /^((0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)?[0-9]{2})*$/; console.log(value); if(reGoodDate.test(value)) { $.each(Page_Validators, function (index, validator){ if (validator.validationGroup == "x"){ ValidatorEnable(validator, true); } }); } else { ValidatorEnable(validator, false); } if(reGoodDate.test(v)) { $.each(Page_Validators, function (index, validator){ if (validator.validationGroup == "y"){ ValidatorEnable(validator, true); } }); } else { ValidatorEnable(validator, false); } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload