September 30th, 2011
alex
Only one right silution: to add timeout for 1ms before destroying the jQuery UI’s draggable/selectable
Source: Bug on destroying jQuery UI’s selectable. | Lost in IT world.
I’ve coded small function that allows filter user input to <input> fields.
It allows to press 0-9 keys (incl. NumPad keys), “,” and “.”, Backspace.
It’s enought to write float value.
$(':input.onlynum').keypress(function(event) {
if (
// numbers
(event.which < 48 || event.which > 57) &&
// .,
event.which != 44 && event.which != 46 &&
// backspace
event.which != 8
) {
event.preventDefault();
return;
}
})
HTML:
Try to input non-numeric symbols:
<input class="onlynum">