regex 1-9999 for form validation

前端 未结 4 1274

I am trying to write some form validation, I need one of the inputs to be 1-9999. I know nothing about regular expressions ( never used them before) and here is my first attempt

4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-21 16:09

    Try using this

    ^([1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9])$
    

提交回复
热议问题