473,698 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validators are all firing

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="baselin e">
<td align="right" valign="middle" nowrap>Password :</td>
<td>
<asp:textbox id="password1" TextMode="Passw ord" Columns="45"
runat="server" /><asp:label text=" 6-20 characters with at least 1 numeric"
style="color:re d" runat="server"/>
<asp:RegularExp ressionValidato r
ControlToValida te="password1"
Display="Dynami c"
Text="<br>Your password must contain between 6 and 20 characters!"
ValidationExpre ssion="\w{6,20} "
Runat="Server" />
<asp:RequiredFi eldValidator id="RequiredFie ldValidator"
ControlToValida te="password1"
Display="Dynami c"
ErrorMessage="A password must be entered!"
runat="server"/>
<asp:RegularExp ressionValidato r
ControlToValida te="password1"
Display="Dynami c"
Text="<br>Your password must contain at least one number and
letter!"
ValidationExpre ssion="[a-zA-Z]+\w*\d+\w*"
Runat="Server" />
</td>
</tr>
</div>
<div id="retypePassw ord" visible="false" runat="server">
<tr valign="baselin e">
<td align="right" valign="middle" nowrap>Retype Password:</td>
<td>
<asp:textbox id="password2" TextMode="Passw ord" Columns="45"
runat="server" />
<asp:CompareVal idator
ControlToValida te="password1"
ControlToCompar e="password2"
Display="Dynami c"
Text="<br>Your passwords don't match!"
Operator="Equal "
Type="String"
Runat="Server" />
</td>
</tr>
*************** *************** *************** *************** **************

Thanks,

Tom
Nov 19 '05 #1
1 1149
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


"tshad" wrote:
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="baselin e">
<td align="right" valign="middle" nowrap>Password :</td>
<td>
<asp:textbox id="password1" TextMode="Passw ord" Columns="45"
runat="server" /><asp:label text=" 6-20 characters with at least 1 numeric"
style="color:re d" runat="server"/>
<asp:RegularExp ressionValidato r
ControlToValida te="password1"
Display="Dynami c"
Text="<br>Your password must contain between 6 and 20 characters!"
ValidationExpre ssion="\w{6,20} "
Runat="Server" />
<asp:RequiredFi eldValidator id="RequiredFie ldValidator"
ControlToValida te="password1"
Display="Dynami c"
ErrorMessage="A password must be entered!"
runat="server"/>
<asp:RegularExp ressionValidato r
ControlToValida te="password1"
Display="Dynami c"
Text="<br>Your password must contain at least one number and
letter!"
ValidationExpre ssion="[a-zA-Z]+\w*\d+\w*"
Runat="Server" />
</td>
</tr>
</div>
<div id="retypePassw ord" visible="false" runat="server">
<tr valign="baselin e">
<td align="right" valign="middle" nowrap>Retype Password:</td>
<td>
<asp:textbox id="password2" TextMode="Passw ord" Columns="45"
runat="server" />
<asp:CompareVal idator
ControlToValida te="password1"
ControlToCompar e="password2"
Display="Dynami c"
Text="<br>Your passwords don't match!"
Operator="Equal "
Type="String"
Runat="Server" />
</td>
</tr>
*************** *************** *************** *************** **************

Thanks,

Tom

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
2017
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These controls and validators are then added to a table for display to the user. This code did seem to work originally, but now does not amd I am stumped as to why. There have been some code changes, but not to the methods below and I have pretty much...
0
1909
by: Tom Pearson | last post by:
I create controls and validators dynamically dependent on data at runtime. I create the control then the relevant validator(s) for it assigning the Control.ID as the control to validate. These controls and validators are then added to a table for display to the user. This code did seem to work originally, but now does not amd I am stumped as to why. There have been some code changes, but not to the methods below and I have pretty much...
2
1725
by: RichieRich | last post by:
Does anyone know if it is possible? If I have two buttons on a page and in my OnServerValidate function can I figure out which button was pressed. I need to know because I have validators on the page that I do not want to enable when a specific button is pressed. Thanks in advance.
7
1353
by: angus | last post by:
Dear all, I have 5 textboxes, and 2 buttons in a webform. 1-3 textboxes would be validated by 3 Required Field Validators if button 1 is click; 4-5 textboxes would be validated by 2 Required Field Validators if button 2 is click. I have found whether i click button 1 or button 2, textboxes 1-5 will be
5
1655
by: John Abbler | last post by:
I'm currently testing doing some testing with other browsers and have found that my custom field validators aren't firing with Firefox or Netscape, but they work fine with Ie. Here's the code I'm using: <asp:CustomValidator id="vld1PaymentType" ClientValidationFunction="ValidateRadiobutton" runat="server" ErrorMessage="Payment Type must be selected" CssClass="ValidationMessage"></asp:CustomValidator>
4
1421
by: Alan Silver | last post by:
Hello, I have a page with some validators, all of which work fine. I want to add a Cancel button to the page, so that if the user decides not to fill in the form, they can click Cancel and go back to where they were before. Trouble is that clicking the Cancel button fires the validators and stops the page being submitted. How can I get around this?
0
320
by: Mike Collins | last post by:
I have a form where I create dynamic controls at runtime. With this, I am adding a dynamic required field validators to each control as needed, but the validators are not firing when I click submit. The submit button was placed at design time and its causesvalidation property is set to true. Can someone tell me if something is missing from my code? Thank you. 1. Code to add dynamic control works fine and I get the Id of the textbox...
1
3099
by: Andrew Jocelyn | last post by:
Hi I have a Formview control in a UserControl. The server-side validation is not working, i.e. the events are not firing when a button control which causes validation is fired or even when Page.Validate() is explicitly called. I'm loading the FormView as an IBindableTemplate as in this article but I don't think this is the reason for the validation not working. http://www.developerfusion.co.uk/show/4721/
2
1813
by: Alec MacLean | last post by:
Hi, I have a page using AJAX. The page has three modal popups that work fine when I don't have field validators in place. As soon as I put a validator in place, the popup "form" the validator is part of still works, but the click events (postback) of the other popups is stopped. So, I have two data entry forms I want to validate, each within their own modal Popup panels. The system detects the user type accessing the page and this...
0
8598
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9152
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8855
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7708
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5857
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4612
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3037
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2320
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.