jquery
$(".numeric").bind("keypress", function (e) {
var keyCode = e.which ? e.which : e.keyCode
var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
return ret;
});
Html
<input type="text" class="numeric" id ="txt"/>
Here the code is working fine to validate numeric values with decimal.
But I want negative values to be included in the validation like -1.23,-2.23,-37.856,etc.
Note: The - symbol should appear only at the beginning and should be optional.