Oct 18, 2007 #1 checkai Programmer Joined Jan 17, 2003 Messages 1,629 Location 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..."
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..."
Oct 18, 2007 #2 tsuji Technical User Joined Jul 25, 2001 Messages 10,675 Location US [tt]var rx=/^([0-9]|[1-9][0-9]|100)$/; //whitespace unpardoning[/tt] Upvote 0 Downvote
Oct 18, 2007 #3 kaht Programmer Joined Aug 18, 2003 Messages 4,156 Location US 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 Upvote 0 Downvote
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
Oct 18, 2007 #4 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi Just for curiosity, why did you wrote the '0*' 3 times ? Code: var rx=/^[red]0*[/red]([0-9]|[1-9][0-9]|100)$/; Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Just for curiosity, why did you wrote the '0*' 3 times ? Code: var rx=/^[red]0*[/red]([0-9]|[1-9][0-9]|100)$/; Feherke. http://rootshell.be/~feherke/
Oct 18, 2007 #5 kaht Programmer Joined Aug 18, 2003 Messages 4,156 Location US Just for curiosity, why did you wrote the '0*' 3 times ? Click to expand... 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 Upvote 0 Downvote
Just for curiosity, why did you wrote the '0*' 3 times ? Click to expand... 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