Created
March 8, 2023 07:58
-
-
Save al5dy/6ba97be2c6ff72788b9bda568039e2b0 to your computer and use it in GitHub Desktop.
Allow input only numbers, dot and comma for field
This file contains 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
$("[data-allow-comma]").on("keypress keyup blur",function (event) { | |
$(this).val($(this).val().replace(/[^0-9\.|\,]/g,'')); | |
if(event.which == 44) | |
{ | |
return true; | |
} | |
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57 )) { | |
event.preventDefault(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment