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)$
if you want to check for age between for example 18 or 70 I did it like this. my solution was
function yearRange(year) { let now = new Date().getFullYear(); let age = now - Number(year); if (age < 18 || age > 70) return false; return true; }