473,569 Members | 2,572 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:regularexp ressionvalidato r id="RegularExpr essionValidator 1"
runat="server" ControlToValida te="txtEmail" ErrorMessage="P lease enter a
valid email address"

ValidationExpre ssion="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg
ularexpressionv alidator>
Nov 18 '05 #1
2 1434

"Stu" <st************ @exeterfriendle e.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:regularexp ressionvalidato r id="RegularExpr essionValidator 1"
runat="server" ControlToValida te="txtEmail" ErrorMessage="P lease enter a
valid email address"

ValidationExpre ssion="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg ularexpressionv alidator>


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 RequiredFieldVa lidator 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******** ********@TK2MSF TNGP12.phx.gbl. ..

"Stu" <st************ @exeterfriendle e.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:regularexp ressionvalidato r id="RegularExpr essionValidator 1"
runat="server" ControlToValida te="txtEmail" ErrorMessage="P lease enter a
valid email address"

ValidationExpre ssion="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:reg
ularexpressionv alidator>


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 RequiredFieldVa lidator 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
2137
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 example, using XPath or Java method. So is there a concept and/or standard for post-schema validation or application validation? Is there any hook in XML...
9
2330
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 "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> When I change the DOCTYPE to (what should be the...
16
2213
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 individual fields, such as an "Email Validation Script" or a "Phone Validation Script". Is it ok to put all these scripts on page as they are or should they...
1
1620
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 range, which at the lower end is >= 0 and the upper limit is configurable, these totals are then submitted to a web service which posts them to a data...
14
6277
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) show the error message next to the control. For example, if the text field is empty with RequiredField Validator control, it can show the value in...
5
3231
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 I use an argument to difference between an 'edit' vs. and 'add. But since I have field validation on both 'footer' and 'edit' columns I can't submit...
8
1197
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 in Internet Explorer but I noticed that in FireFox, Netscape and Mozilla, they don’t work. These validation controls are set to run servside...
2
9088
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 anyone please help me with this? I am attaching my code piece. Thank you in advance for your help. Wing
9
4160
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 honest I usually hire someone to do it for me, grab predone scripts and kind of hack out the parts that I need, or just do very minimal validation...
27
4701
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 appears that the data goes straight to the processing page, rather than the javascript seeing if data is missing and popping up an alert. I thought it...
0
7614
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...
1
7676
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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...
1
5513
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5219
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...
0
3653
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2114
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
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
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...

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.