473,503 Members | 2,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validation question

Stu
I'm using the following validation code in an aspx form page, its the
standard email validation provided with MSVS 2003.

My question is how can I have validation triggered only if something has
been entered in the text box, i.e. email is not a required field, but if the
punter decides to let us have it I'd like it to be validated.

Bit new on C# and MSVS2003, so sorry if its a daft question.

Look forwarded to your replies.

Stu

<asp:regularexpressionvalidator id="RegularExpressionValidator1"
runat="server" ControlToValidate="txtEmail" ErrorMessage="Please enter a
valid email address"

ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg
ularexpressionvalidator>
Nov 18 '05 #1
2 1432

"Stu" <st************@exeterfriendlee.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
I'm using the following validation code in an aspx form page, its the
standard email validation provided with MSVS 2003.

My question is how can I have validation triggered only if something has
been entered in the text box, i.e. email is not a required field, but if the punter decides to let us have it I'd like it to be validated.

Bit new on C# and MSVS2003, so sorry if its a daft question.

Look forwarded to your replies.

Stu

<asp:regularexpressionvalidator id="RegularExpressionValidator1"
runat="server" ControlToValidate="txtEmail" ErrorMessage="Please enter a
valid email address"

ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg ularexpressionvalidator>


That is the behavior you have now! All validators (except RequiredField)
ignore
"empty" fields (it seems that spaces are also ignored). So if you want a
required
field, you have to use the RequiredFieldValidator along with possible
others.

Hans Kesting
Nov 18 '05 #2
Stu
Thanks Hans

That will teach me to make assumptions and not test things properly before I
post !!!!

Stu


"Hans Kesting" <ne***********@spamgourmet.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...

"Stu" <st************@exeterfriendlee.co.uk> wrote in message
news:10***************@ananke.eclipse.net.uk...
I'm using the following validation code in an aspx form page, its the
standard email validation provided with MSVS 2003.

My question is how can I have validation triggered only if something has
been entered in the text box, i.e. email is not a required field, but if

the
punter decides to let us have it I'd like it to be validated.

Bit new on C# and MSVS2003, so sorry if its a daft question.

Look forwarded to your replies.

Stu

<asp:regularexpressionvalidator id="RegularExpressionValidator1"
runat="server" ControlToValidate="txtEmail" ErrorMessage="Please enter a
valid email address"

ValidationExpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg
ularexpressionvalidator>


That is the behavior you have now! All validators (except RequiredField)
ignore
"empty" fields (it seems that spaces are also ignored). So if you want a
required
field, you have to use the RequiredFieldValidator along with possible
others.

Hans Kesting

Nov 18 '05 #3

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

Similar topics

2
2132
by: wumingshi | last post by:
Hi, When validating an XML instance, sometimes the schema is not enough to expression the validation rules. Additional validation rules may be expressed in an application-specific way. For...
9
2327
by: rbronson1976 | last post by:
Hello all, I have a very strange situation -- I have a page that validates (using http://validator.w3.org/) as "XHTML 1.0 Strict" just fine. This page uses this DOCTYPE: <!DOCTYPE html PUBLIC...
16
2192
by: Hosh | last post by:
I have a form on a webpage and want to use JavaScript validation for the form fields. I have searched the web for form validation scripts and have come up with scripts that only validate...
1
1613
by: Colin Basterfield | last post by:
Hi, I have a web form which takes daily sales totals, both counts and monetary value and is done on a weekly basis, so on a Monday morning the User would enter these totals. Each total has a...
14
6268
by: Matt | last post by:
I want to know if ASP.NET Web Forms Validation Controls are Server-Side or Client-Side form validation? Since I think each validator control can select either 1) JavaScript based error dialog or 2)...
5
3223
by: Chris | last post by:
Based upon some prevoius postings on what to do for adding a 'add' row to a datagrid I utilize the footer to create the 'add' row. The only issue is that I have it sharing the 'UpDate_Command' and...
8
1191
by: Joe | last post by:
Hi, I have a form with three text fields and a Submit button. The two text fields have ReqiredFieldValidator and third text field has RegularExpressionValidator. The page validation works fine...
2
9081
by: winnie_us99 | last post by:
Hi All, I am trying to do validation on my text field before going to the next page to create a user. It doesn't look like the next button will fire any validation. Am I missing something? Can...
9
4153
by: julie.siebel | last post by:
Hello all! As embarrassing as it is to admit this, I've been designing db driven websites using javascript and vbscript for about 6-7 years now, and I am *horrible* at form validation. To be...
27
4679
by: Chris | last post by:
Hi, I have a form for uploading documents and inserting the data into a mysql db. I would like to validate the form. I have tried a couple of Javascript form validation functions, but it...
0
7093
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...
1
7011
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7468
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...
0
5596
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,...
0
4689
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...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3170
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1521
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 ...
0
401
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...

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.