Regex: how to only allow integers greater than zero

后端 未结 6 1006
失恋的感觉
失恋的感觉 2021-01-20 00:42

I have tried the following to only allow integers in my text box, this works great but it allows a zero in there. Is there anything else I can add to prevent a zero being ad

6条回答
  •  一个人的身影
    2021-01-20 00:53

    This will allow 10 but not 01, and it will allow only numbers consisting of digits, i.e., no periods or minus signs...but also no plus signs, scientific notation etc.

    ^[1-9][0-9]*$
    

提交回复
热议问题