Validators are all firing

T

tshad

Is there a way to tell the validators to not fire if one of the validators
fails the input?

For example:

In the following code, if someone doesn't enter anything in the field, I
should get the message " A password must be entered".

I am also getting the message that I need " 1 numeric", "the passwords don't
match" and "I need from 6 - 20 characters".

I would like to only get the first message, which ever it is.

*********************************************************************************
<tr valign="baseline">
<td align="right" valign="middle" nowrap>Password:</td>
<td>
<asp:textbox id="password1" TextMode="Password" Columns="45"
runat="server" /><asp:label text=" 6-20 characters with at least 1 numeric"
style="color:red" runat="server"/>
<asp:RegularExpressionValidator
ControlToValidate="password1"
Display="Dynamic"
Text="<br>Your password must contain between 6 and 20 characters!"
ValidationExpression="\w{6,20}"
Runat="Server" />
<asp:RequiredFieldValidator id="RequiredFieldValidator"
ControlToValidate="password1"
Display="Dynamic"
ErrorMessage="A password must be entered!"
runat="server"/>
<asp:RegularExpressionValidator
ControlToValidate="password1"
Display="Dynamic"
Text="<br>Your password must contain at least one number and
letter!"
ValidationExpression="[a-zA-Z]+\w*\d+\w*"
Runat="Server" />
</td>
</tr>
</div>
<div id="retypePassword" visible="false" runat="server">
<tr valign="baseline">
<td align="right" valign="middle" nowrap>Retype Password:</td>
<td>
<asp:textbox id="password2" TextMode="Password" Columns="45"
runat="server" />
<asp:CompareValidator
ControlToValidate="password1"
ControlToCompare="password2"
Display="Dynamic"
Text="<br>Your passwords don't match!"
Operator="Equal"
Type="String"
Runat="Server" />
</td>
</tr>
**************************************************************************

Thanks,

Tom
 
G

Guest

Hi,

I don't think that it is possible. 'Coz... all validator controls are not
having any events ...so that you can't cotrol from your code behind like....

If (Is validator1 fired) then

disable validator2

else
enable validator2

end if.

You can write your own validators by inheriting the existing validating
scripts and you can try to achieve this.

Cheers,

Jerome. M
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,068
Latest member
MakersCBDIngredients

Latest Threads

Top