Connecting Tech Pros Worldwide Forums | Help | Site Map

Regular Expression Validator

war war is offline
Newbie
 
Join Date: Oct 2007
Posts: 5
#1: Oct 11 '07
Hi ,
I am Having a doubt in Regular expression validator,Since i am not aware of that

i am having a text box it should accept any integer value upto 8 digit and it also should accept decimal if so it should accept only two digits after the decimal point

can u guide me.
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#2: Oct 11 '07

re: Regular Expression Validator


Hi,
I have been playing with regex's a bit.
But am still very crude at it.
How does this look?
[1-9][0-9]{0,7}[.][0-9]{2}
I tried it and it works

cheers
war war is offline
Newbie
 
Join Date: Oct 2007
Posts: 5
#3: Oct 11 '07

re: Regular Expression Validator


Quote:

Originally Posted by Shashi Sadasivan

Hi,
I have been playing with regex's a bit.
But am still very crude at it.
How does this look?
[1-9][0-9]{0,7}[.][0-9]{2}
I tried it and it works

cheers


Hi,

Thanx a lot

its working but still have a doubt the thing is consider a person should enter marks some people will be getting decimals too.so my text box should accept both integers and decimals too.and if decimal occurs it should be upto 2 digits only.
Kindly note Decimal is not a compulsory One .
And my Maxlength Property of my Textbox is 8.
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#4: Oct 11 '07

re: Regular Expression Validator


there you go then.....
A little tutorial for you :)
war war is offline
Newbie
 
Join Date: Oct 2007
Posts: 5
#5: Oct 11 '07

re: Regular Expression Validator


Quote:

Originally Posted by Shashi Sadasivan

there you go then.....
A little tutorial for you :)

Hi,
thanx.

but the material is littlebit confusing can u solve that to me,if u are willing.

Have a plesant day
war war is offline
Newbie
 
Join Date: Oct 2007
Posts: 5
#6: Oct 11 '07

re: Regular Expression Validator


Hi,

Consider a scenario,
People should enter amount in price textbox.
since people vary from each others ,some enter a int(eg 1245) and some may enter (eg 456.50 ) so my textbox should accept both the whole numbers and decimal numbers.

And my Textbox length is 8.

Can any one clearly guide or give the expression .bcoz i am new to validation control
If am using this [1-9][0-9]{0,7}[.][0-9]{2} its not accepting whole numbers accepting only decimal numbers so i want tht decimal symbol should be optional
kenobewan's Avatar
Moderator
 
Join Date: Dec 2006
Posts: 4,745
#7: Oct 11 '07

re: Regular Expression Validator


Last time I had an optional expression I used two expressions. HTH.
Shashi Sadasivan's Avatar
Moderator
 
Join Date: Aug 2007
Location: Brisbane, Australia
Posts: 1,414
#8: Oct 11 '07

re: Regular Expression Validator


Quote:

Originally Posted by kenobewan

Last time I had an optional expression I used two expressions. HTH.

2 expressions, yea, thanks for that....I just discovered you can put in 2 expressions and either one can be matched.....
Is regex the most compact language made :P
Reply