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

regex onBlur input between 1900 and 2050 1

Status
Not open for further replies.

copeZero

Programmer
Aug 31, 2007
46
0
0
CA
Hi i was wondering how one would check using regex if an input of a text box is between the numbers of 1900 and 2050

Thanks
 
[tt]var s="2007"; //the input retrieved as sting
var rx=/^(19[0-9]{2}|20[0-4][0-9]|2050)$/;
if (rx.test(s)) {
//within the range
} else {
//outside of the range
}[/tt]
 
Thanks, that looked like it took some brilliance for: 20[0-4][0-9]|2050


Do u do contract work?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top