I am trying to check my asp.net text box to only accept numbers and '.'
To do this, I wrote a function using the Internet (sorry I'm new to jQuery)
Jquery
$('#<%= txtWidth.ClientID %>').keypress(function (event) {
$(this).val($(this).val().replace(/[^0-9\.]/g, ''));
if ((event.which != 46 || $(this).val().indexOf('.') != -1) && (event.which < 48 || event.which > 57)) {
event.preventDefault();
}
});
});
It works fine, but Delete and Backspace do not work. How to enable the inclusion of these keys with keys? What changes do I need to make?
Please help this newbie ..
source
share