jquery - Allow Decimal value in number -


i have form filed in amount has enter. amount separated commas , decimal not allowed. want allow decimal in amount. in advance...

here code :

(function($, undefined) {      "use strict";       $(function() {          var $form = $( ".number" );         var $input = $form.find( ".no" );          $input.on( "keyup", function( event ) {              var selection = window.getselection().tostring();             if ( selection !== '' ) {                 return;             }               if ( $.inarray( event.keycode, [38,40,37,39] ) !== -1 ) {                 return;             }               var $this = $( );               var input = $this.val();              var input = input.replace(/[\d\s\._\-]+/g, "");             input = input ? parseint( input, 10 ) : 0;              $this.val( function() {                 return ( input === 0 ) ? "" : input.tolocalestring( "en-us" );             });          });        });  })(jquery); 

$(function() {  var $form = $( ".number" ); var $input = $form.find( ".no" );  $input.on( "keyup", function( event ) {        var selection = window.getselection().tostring();     if ( selection !== '' ) {         return;     }       if ( $.inarray( event.keycode, [38,40,37,39] ) !== -1 ) {         return;     }       var $this = $( );       var input = $this.val();              input = input ? parsefloat( input) : 0;              $this.val( function() {                 return ( input === 0 ) ? "" : input.tolocalestring( "en-us" );             } ); } );      });    })(jquery); 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -