Answers for "allow only integer or float in text fields jQuery"

1

allow only integer or float in text fields jQuery

$(function(){
      
  $('.number-only').keyup(function(e) {
        if(this.value!='-')
          while(isNaN(this.value))
            this.value = this.value.split('').reverse().join('').replace(/[\D]/i,'')
                                   .split('').reverse().join('');
    })
    .on("cut copy paste",function(e){
    	e.preventDefault();
    });

});
Posted by: Guest on June-03-2021

Code answers related to "allow only integer or float in text fields jQuery"

Browse Popular Code Answers by Language