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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular expression to test number range

Status
Not open for further replies.

VBGuy2112

Programmer
Feb 19, 2002
58
US
I'm looking for a regular expression to test that a number is within a range (like between 1 and 3000). Does anyone know how to do this? I know how to see that they've entered in a 4-digit number, but not how to see that it isn't greater than 3000.


Thanks!
 
VBGuy2112,

This is something that can be pretty quickly done using an ordinary comparison:

Code:
if(TestNumber<3000)
  { alert(&quot;Most excellent number, dude!&quot;); }
else
  { alert(&quot;Major bogosity on your number, dude!&quot;); }

If you want a RegEx, it would just replace the contents of the parenthesis above.

Good luck!
[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top