Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Sir/ Madam....!!!


In Salary Field , the range must be 10000 to 50000.

How to set regular expression???

please Help Me Out...!!!!

ThankQ.
Posted

Hi friend,

Please see below code for Email Address regular expression validations use :

<asp:textbox id="txtEmailAddress" runat="server" width="200px" cssclass="textBoxStyle" xmlns:asp="#unknown">
                             Height="20px"></asp:textbox>
                         <asp:regularexpressionvalidator id="RevEmailAddress" runat="server" errormessage="*" xmlns:asp="#unknown">
                             ValidationGroup="SignUp" ControlToValidate="txtEmailAddress" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:regularexpressionvalidator>


you have to change ValidationExpression Attribute value as per your need like in your case you have to set it for Salary.

one more think the you want to Set the range validation then you bust have to use range validator control

i.e Example
<asp:rangevalidator id="RangeValidator1" runat="server" errormessage="RangeValidator" maximumvalue="50000" minimumvalue="10000" xmlns:asp="#unknown"></asp:rangevalidator>


Hope this will helps you:)
 
Share this answer
 
Comments
Prasad Guduri 8-Jan-12 2:37am    
Really Thanks a Lot Friend....!!!
Why do you think you should stick regular exception into any… I mean, validation? :-)

Do the following: first, validate that a value is numeric using [0-9], and then parse the string into integer using int.TryParse(string) (it may also return false if there are too many digits) and finally, test integer result for being in the required length. Simple, isn't it?

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900