Skip to content

Instantly share code, notes, and snippets.

@jamalnasir
Created October 25, 2017 07:23
Show Gist options
  • Save jamalnasir/5f1f4c3b16c610a95d2ef50c1802c95b to your computer and use it in GitHub Desktop.
Save jamalnasir/5f1f4c3b16c610a95d2ef50c1802c95b to your computer and use it in GitHub Desktop.
This script allow only numeric values in the text fields
$('body').on('keydown', 'input[name=random]', function(e) {
return ((e.keyCode >= 48 && e.keyCode <= 57) || (e.keyCode >= 96 && e.keyCode <= 105) || e.keyCode == 173 || e.keyCode == 8 || e.keyCode == 9) ? true : false;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment