Created
May 1, 2018 06:11
-
-
Save anshuraj/622066b3bdd1edeb276579e38d54f509 to your computer and use it in GitHub Desktop.
input field restrict to 2 digits after decimal
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('.decimal').keypress(function (e) { | |
var character = String.fromCharCode(e.keyCode) | |
var newValue = this.value + character; | |
if(newValue.toString().split('.')[1].length > 2) { | |
e.preventDefault(); | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment