I have never managed to properly understand regular expressions, as far as I
am concerned they are some kind of gobldegook that performs magic voodoo.
However i have a TextBox that must be set to one of three values VS,WS or FP.
Right i thought even i can manage a regular expression that does that. I
created a RegularExpressionValidator, pointed it at the relevent control and
set the ValidationExpression to VS|WS|FP But it does not work. If is set it
to vs|ws|fp it correctly validates agains vs,fp or ws but the values have to
be in uppercase. What really simple and obvious thing am i missing. 6 1103
You're not missing anything, Regular Expressions are case sensitive by
nature, and the RegularExpressionValidator doesn't support clientside
case insensitivity. You can add the modifier so you'd have
"(?i:vs|ws|fp) but that'll choke if you don't turn off the clientside
support.
In Javascript you want var myRegEx = /vs|ws|fp/i;
But i want it to be case sensitive, and it sort of is in that if i set the
ValidationExpression to vs|ws|fp then it will only allow me to enter vs, ws
or fp but not VS,WS or FP. But i want it to do the oposite allow VS, WS or
FP but not vs,ws or fp (or any other string). But if i set the
ValidationExpression to VS|WS|FP then fails validation whatever i do,
uppercase or lowercase.
"Flinky Wisty Pomm" wrote: You're not missing anything, Regular Expressions are case sensitive by nature, and the RegularExpressionValidator doesn't support clientside case insensitivity. You can add the modifier so you'd have "(?i:vs|ws|fp) but that'll choke if you don't turn off the clientside support.
In Javascript you want var myRegEx = /vs|ws|fp/i;
It worked fine with me:
<asp:TextBox ID="txtBox1" Runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="valtxtBox1" Runat="server"
ValidationExpression="^VS|WS|FP$"
ErrorMessage="Invalid entries"
Display="Dynamic"
ControlToValidate="txtBox1">
</asp:RegularExpressionValidator>
--
HTH,
Phillip Williams http://www.societopia.net http://www.webswapp.com
"clickon" wrote: But i want it to be case sensitive, and it sort of is in that if i set the ValidationExpression to vs|ws|fp then it will only allow me to enter vs, ws or fp but not VS,WS or FP. But i want it to do the oposite allow VS, WS or FP but not vs,ws or fp (or any other string). But if i set the ValidationExpression to VS|WS|FP then fails validation whatever i do, uppercase or lowercase.
"Flinky Wisty Pomm" wrote:
You're not missing anything, Regular Expressions are case sensitive by nature, and the RegularExpressionValidator doesn't support clientside case insensitivity. You can add the modifier so you'd have "(?i:vs|ws|fp) but that'll choke if you don't turn off the clientside support.
In Javascript you want var myRegEx = /vs|ws|fp/i;
Take the user input from the textbox and create a string i.e.
string _strToCheck = _tbInput.Text.ToLower();
Now run your Regular Expression server side. This way you can control
how the input is formatted.
Regex _strPattern = new Regex(@"="^vs|ws|fp$",
RegexOptions.IgnoreCase);
Match _matches = _strPattern.Match(_strToCheck);
string _patternMatch = _matches.ToString();
Don't forget to use the System.Text.RegularExpressions namespace.
This is how I would go about doing this. But to each his/her own....
- Will
Almost forgot, easier method!
Change the css attributes of your textbox so that by default input is
Upper-case.
text-transform: uppercase (i think)
Right, on further investiagtion it apears not to be a problem with the
validation expresion but a problem with actual validation taking place. The
textbox being validated is being filled with a value from a database, when
the page loads it apears as though the validation for this textbox has
already failed, in that the error message is displayed, however the value in
the textbox is valid. However if you do something to re-trigger validation
such as causing a postback then it validates OK. At this point it has failed
validation and then passed it without ever changing the value in the control
being validated. anyone any idea what is going on hear.
"Phillip Williams" wrote: It worked fine with me:
<asp:TextBox ID="txtBox1" Runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="valtxtBox1" Runat="server" ValidationExpression="^VS|WS|FP$" ErrorMessage="Invalid entries" Display="Dynamic" ControlToValidate="txtBox1"> </asp:RegularExpressionValidator> -- HTH, Phillip Williams http://www.societopia.net http://www.webswapp.com
"clickon" wrote:
But i want it to be case sensitive, and it sort of is in that if i set the ValidationExpression to vs|ws|fp then it will only allow me to enter vs, ws or fp but not VS,WS or FP. But i want it to do the oposite allow VS, WS or FP but not vs,ws or fp (or any other string). But if i set the ValidationExpression to VS|WS|FP then fails validation whatever i do, uppercase or lowercase.
"Flinky Wisty Pomm" wrote:
You're not missing anything, Regular Expressions are case sensitive by nature, and the RegularExpressionValidator doesn't support clientside case insensitivity. You can add the modifier so you'd have "(?i:vs|ws|fp) but that'll choke if you don't turn off the clientside support.
In Javascript you want var myRegEx = /vs|ws|fp/i;
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Kenneth McDonald |
last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate
feedback, suggestions, and criticism as I work towards finalizing the
API and feature sets. rex is a module intended to make...
|
by: Buddy |
last post by:
Can someone please show me how to create a regular expression to do the
following
My text is set to
MyColumn{1, 100} Test
I want a regular expression that sets the text to the following...
|
by: Neri |
last post by:
Some document processing program I write has to deal with documents
that have headers and footers that are unnecessary for the main
processing part. Therefore, I'm using a regular expression to go...
|
by: Dimitris Georgakopuolos |
last post by:
Hello,
I have a text file that I load up to a string. The text includes
certain expression like {firstName} or {userName} that I want to match
and then replace with a new expression. However,...
|
by: James D. Marshall |
last post by:
The issue at hand, I believe is my comprehension of using regular
expression, specially to assist in replacing the expression with other text.
using regular expression (\s*) my understanding is...
|
by: Billa |
last post by:
Hi,
I am replaceing a big string using different regular expressions (see
some example at the end of the message). The problem is whenever I
apply a "replace" it makes a new copy of string and I...
|
by: Mike |
last post by:
I have a regular expression (^(.+)(?=\s*).*\1 ) that results in
matches. I would like to get what the actual regular expression is.
In other words, when I apply ^(.+)(?=\s*).*\1 to " HEART...
|
by: Allan Ebdrup |
last post by:
I have a dynamic list of regular expressions, the expressions don't change
very often but they can change. And I have a single string that I want to
match the regular expressions against and find...
|
by: NvrBst |
last post by:
I want to use the .replace() method with the regular expression /^ %VAR
% =,($|&)/. The following DOESN'T replace the "^default.aspx=,($|&)"
regular expression with "":...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |