Javascript function need allow numbers, dot and comma

前端 未结 6 1959
悲&欢浪女
悲&欢浪女 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:11

    Sometimes /^[0-9.,]+$/ is not work If not, then you could do something like this:

    /^(?:[\d-]*,?[\d-]*\.?[\d-]*|[\d-]*\.[\d-]*,[\d-]*)$/
    

提交回复
热议问题