Sha256: a43f7be3fce29b23d8b85536e3c7ef7abcc36b8e17b7ef821ad4194495f5fd1f
Contents?: true
Size: 832 Bytes
Versions: 54
Compression:
Stored size: 832 Bytes
Contents
// Restrict numeric input for a text field // TODO - consider switching to HTML5's <input type="number" /> function preventNonNumericValues(event) { // Allow: backspace, delete, tab, escape, and enter if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || // Allow: Ctrl+A (event.keyCode == 65 && event.ctrlKey === true) || // Allow dot (event.keyCode == 190) || // Allow: home, end, left, right (event.keyCode >= 35 && event.keyCode <= 39)) { // let it happen, don't do anything return; } else { // Ensure that it is a number and stop the keypress if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) { event.preventDefault(); } } }
Version data entries
54 entries across 54 versions & 1 rubygems