I have input field for year and I need a regex for validation it. I have such code: ^([12]\\d)?(\\d\\d)$. But I want allow to validate only years in certain range (
^([12]\\d)?(\\d\\d)$
Regex:
/^(19[5-9]\d|20[0-4]\d|2050)$/
Easier...
var year = parseInt(textField.value, 10); if( year >= 1950 && year <= 2050 ) { ... }