Regex to allow only a single dot in a textbox

前端 未结 4 1262
执念已碎
执念已碎 2020-12-16 06:19

I have one text input.

I wrote a regex for masking all special characters except . and -. Now if by mistake the user enters two .

4条回答
  •  时光说笑
    2020-12-16 06:24

    if you just want to handle number ,you can try this:

    valueTest.match(/^-?\d+(\.\d+)?$/)
    

提交回复
热议问题