Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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();
    });

});
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #integer #float #text #fields #jQuery
ADD COMMENT
Topic
Name
6+8 =