I have a text box where I restrict user from typing anything other than numeric values. Only 0-9 allowed using jQuery.
My code:
if (event.which < 46 || event.which > 59)
event.preventDefault();
Now, I want to allow a negative sign (only at beginning) with numeric like (-12,-13)
. I should restrict these scenarios (--1,-1-,1----)
. Only valid negative numbers should be allowed.
How can I do this using jQuery?