Regular Expressions Problem

  • Thread starter Thread starter kieran
  • Start date Start date
K

kieran

Hi,

I am using Visual Studio 2005 and am trying to use a Regular Expression
Validator control.

I have a drop down list which contains various names, the first one is
"Please Select". I want the user to have to select a name other than
'Please Select'.

I am thinking maybe the Regular Expression Validator is the best move
for this. How would i go about telling the Validator that
ddlApprovers.selectedvalue should not equal "Please select".

I have seen articles on writing and compiling your own validators...is
this the only way to do this...or is there some quicker way.

I know i can do this server side but i want something to work client
side.


Thanks...
 
Dear kieran,

For the Regular Expression Validator, its propose is checking the
expression, ie email address, combination of characters, phone number...etc

For your propose, I think there are 2 types validator fits your need.
1) Custom Validator
2) CompareValidator.

As you said, you don't want to use Custom one, so you may try to use Compare
Validator. Just compare the value if it is equal to "Please Select", if it
does, erturn false.


--
Hope this help and welcome to reply the testing result.

Regards
Ken Lin, Kam Hung
Founder and VP of Hong Kong .NET User Group(http://HKNetUG.com)
MCP, MCP+I, MCDST, MCSA, MCSE(NT4 & win2k),
MCSE+I, MCDBA(SQL7 & SQL2K), MCSD(VB6 & .NET), MCAD(.NET)
Microsoft Community Star(Hong Kong & Taiwan)
Microsoft Most Valuable Professional(.NET since 2003)
MCT2004 & 2005
 
Hi kieran,

I'm not familiar with VS 2005, but in VS 2003, a Validator control had
an InitialValue property that allowed you to set the Initial text that
would display in a control (in your case, a DropDownList ). This was
ideal to set the Initial text to something like :"Please select"

Using this along a RequiredFieldValidator, the Validator would fail
only if the selected value remains "Please select".

I don't know if this behaviour is the same in VS 2005, but you can
check it out.

http://msdn2.microsoft.com/en-US/li...rols.requiredfieldvalidator.initialvalue.aspx

Regards,

Cerebrus.
 
Back
Top