jquery keyup function check if number

后端 未结 8 1893
南旧
南旧 2020-12-10 02:59

i am trying to create an input field where the user can only type in numbers. this function is already working almost fine for me:

        $(\'#p_first\').k         


        
8条回答
  •  一向
    一向 (楼主)
    2020-12-10 03:34

    JavaScript:
    
      function isNumberKey(a){
      var x=a.val();
      a.val(x.replace(/[^0-9\.]/g,''));
    
    }
    
    HTML:
    
         
    

提交回复
热议问题