jquery only allow input float number

前端 未结 13 1706
既然无缘
既然无缘 2020-12-01 06:28

i\'m making some input mask that allows only float number. But current problem is I can\'t check if multiple dots entered. Can you check those dots and prevent it for me?

13条回答
  •  萌比男神i
    2020-12-01 07:27

    Below Code I am allowing only Digits and Dot symbol.
    ASCII characters number starts in 47 and ends with 58 and dot value is 190.

       $("#Experince").keyup(function (event) {
            debugger
    
            if ((event.which > 47
                && event.which < 58) ||event.which== 190) {
                 if ($("#Experince").val().length > 3) {
    
            }
            } // prevent if not number/dot
            else {
                 $("#Experince").val($("#Experince").val().slice(0, -1))
            }
    
        });
    

提交回复
热议问题