Javascript function need allow numbers, dot and comma

前端 未结 6 1960
悲&欢浪女
悲&欢浪女 2020-12-09 04:30

I need to create a function to allow numbers dot and comma. So anyone corrects the following function

function on(evt) {
  var theEvent = evt || window.event         


        
6条回答
  •  醉话见心
    2020-12-09 05:34

    Your regex is incorrect.

    var regex = /^[0-9.,]+$/;
    

    Regex javascript, why dot and comma are matching for \

    https://stackoverflow.com/tags/regex/info

提交回复
热议问题