473,382 Members | 1,258 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Regularexpression validator on multiline text box

Follow up to previous question:
Iım trying to validate a multipline asp text box that can have a maximum of
150 word characters but any number of white space, carriage returns or tabs.
I tried several regex that pass testing on regexplib.com but fail on the
page
This for example doesnıt work properly:

ValidationExpression="^\w{1,150}|\s{0,}$"

I get a validation error if any non-word character is added, regardless of
the total length of the string.

I think I'm having a problem because the text box is multiline and the regex
doesn't check it as single line. I have solved that problem before by using
RegexOptions.Singleline in the code behind file but I don't know how to do
that within the asp RegularExpressionValidator tag.
Any idea?
Thanks,
Stephan.

Nov 17 '05 #1
2 9064
Stephan,

You'll need to allow white space characters before, between, and after your
word characters. Try this instead:

^\s*(\w\s*){1,150}\s*$

HTH,
Nicole

"Stephan Bour" <sb***@niaid.nih.gov> wrote in message
news:BBC43274.ADC3%sb***@niaid.nih.gov...
Follow up to previous question:
Iım trying to validate a multipline asp text box that can have a maximum of 150 word characters but any number of white space, carriage returns or tabs. I tried several regex that pass testing on regexplib.com but fail on the
page
This for example doesnıt work properly:

ValidationExpression="^\w{1,150}|\s{0,}$"

I get a validation error if any non-word character is added, regardless of
the total length of the string.

I think I'm having a problem because the text box is multiline and the regex doesn't check it as single line. I have solved that problem before by using RegexOptions.Singleline in the code behind file but I don't know how to do
that within the asp RegularExpressionValidator tag.
Any idea?
Thanks,
Stephan.

Nov 17 '05 #2
So simple and yet it works so well! Thanks a lot,
Stephan.

in article #v*************@TK2MSFTNGP11.phx.gbl, Nicole Calinoiu at
ni*****@somewhere.net wrote on 10/28/03 16:28:
Stephan,

You'll need to allow white space characters before, between, and after your
word characters. Try this instead:

^\s*(\w\s*){1,150}\s*$

HTH,
Nicole

"Stephan Bour" <sb***@niaid.nih.gov> wrote in message
news:BBC43274.ADC3%sb***@niaid.nih.gov...
Follow up to previous question:
Iım trying to validate a multipline asp text box that can have a maximum

of
150 word characters but any number of white space, carriage returns or

tabs.
I tried several regex that pass testing on regexplib.com but fail on the
page
This for example doesnıt work properly:

ValidationExpression="^\w{1,150}|\s{0,}$"

I get a validation error if any non-word character is added, regardless of
the total length of the string.

I think I'm having a problem because the text box is multiline and the

regex
doesn't check it as single line. I have solved that problem before by

using
RegexOptions.Singleline in the code behind file but I don't know how to do
that within the asp RegularExpressionValidator tag.
Any idea?
Thanks,
Stephan.



Nov 17 '05 #3

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

Similar topics

0
by: Stephan Bour | last post by:
Follow up to previous question: Iım trying to validate a multipline asp text box that can have a maximum of 150 word characters but any number of white space, carriage returns or tabs. I tried...
3
by: RSB | last post by:
Hi Guys.. its me again.. ;o)) now i have a TextBox with properties Textmode = singleline and MaxLength = 100. So this works fine and i cannot enter more then 100 Chars. But as soon as i...
2
by: John Hoge | last post by:
I have a regex "^\d{5}$" that does not allow blanks, but the RegularExpressionValidator does not fire for empty fields. Is there a way to make it do so? I would rather not include a separate...
1
by: Nicola Farina | last post by:
Hi all, i've a form with a textbox that user "must" fill with a password. I want to check if there's a password inside, and if it's between 6 an 8 chars. I've placed a regularexpression...
2
by: Alan Silver | last post by:
Hello, I have a custom validator on my page, and have the server-side code working fine. I want to add a client-side funtion as well, but am not sure how to wire it in so that it works with the...
2
by: den 2005 | last post by:
Hi everybody, How do restrict entering these characters <>\"%';()& and telling user these caharcters are not allowed to be enter in the textbox field using RegularExpression Validator? I put in...
3
by: Arpan | last post by:
Consider the following code which validates a TextBox using RegularExpression: <form id="form1" runat="server"> <asp:TextBox id="txt1" runat="server"/> <asp:RegularExpressionValidator...
1
by: prp | last post by:
hi all, I have a problem.Suppose I use a regularexpression validator for zip code. An User fill wrong entry in the relevant textbox then regularexpression validator fires.but user did not...
0
by: dancer | last post by:
Can somebody tell me why my RequiredFieldValidator works for the TEXT BOX, (location) but does NOT work for the RADIO BUTTON (EmpTrain)? <%@ Page Language="VB" ClientTarget="downlevel" %> ...
5
by: hamsterchaos | last post by:
<asp:RegularExpressionValidator id="valRegEx" runat="server" ControlToValidate="textbox1" ValidationExpression=" " ErrorMessage="* Please only enter alphanumeric values and make sure...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.