Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expression: Non Blank Integer

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
US
I'm looking for a regular exp forcing a user to enter a non blank, integer between 0 and 100.

Thanks!

"...your mom goes to college..."
 
[tt]var rx=/^([0-9]|[1-9][0-9]|100)$/; //whitespace unpardoning[/tt]
 
Just for fun, a modification to tsuji's regex to allow leading 0's:
Code:
var rx=/^([!]0*[/!][0-9]|[!]0*[/!][1-9][0-9]|[!]0*[/!]100)$/;

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Just for curiosity, why did you wrote the '0*' 3 times ?

Because I suck.....

-kaht

Lisa, if you don't like your job you don't strike. You just go in every day and do it really half-assed. That's the American way. - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top