Associating RegularExpressionValidator and Require
hi,
How can I associate RequiredFieldValidator and RegularExp
ressionValidator? RegularExpressionValidator doesn't validate a form field unless the form field contains a value. To make the form field required I need to associate it with Requiredfieldvalidator.
please help!
Thank you in advance
here is my code:
<tr>
<td bgcolor="EEEEEE" align="right">number:</td>
<td align="left">
<asp:TextBox id="nrid" runat="server" />
<asp:Requiredfieldvalidator id="nr_required" runat="Server" controltovalidate="nrid" errormessage="number required" />
<asp:RegularExpressionValidator runat="server" ControltoVlidate="nrid" ValidsationExpression="[0-9]{8}" errormessage="not valid number" />
</td>
</tr>
the above code gives me the following error:
The ControlToValidate property of '' cannot be blank.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: The ControlToValidate property of '' cannot be blank.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[HttpException (0x80004005): The ControlToValidate property of '' cannot be blank.]
System.Web.UI.WebControls.BaseValidator.ControlPro pertiesValid() +1840442
System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +33
System.Web.UI.Control.PreRenderRecursiveInternal() +77
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Control.PreRenderRecursiveInternal() +161
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
|