javascript regex validate years in range

后端 未结 8 1109
猫巷女王i
猫巷女王i 2021-02-13 20:11

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 (

8条回答
  •  盖世英雄少女心
    2021-02-13 20:32

    (199[0-9]|200[0-9]|2010)
    

    This will work in your 'example case'.

    Helpful website: http://utilitymill.com/utility/Regex_For_Range

提交回复
热议问题