I am trying to do something like this code below but have so far not being successful.
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57)) return false;
return true;
} // restrict numerical values only
The code above only allows for numerical characters, and when a user push any other key apart from the Numerical ones, it does not appear on the text box.
This is exactly what I want too but the scenario is different, I don't want the user to enter zero (0) as their first character.
e.g. 0909 wrong but instead 909
I have being able to achieve this thus far
$(".input-xlarge").keyup(function () {
var textInField = this.value;
if (textInField.length == 1) {
if (textInField == 0) {
showError('error?');
}
}
});
but instead a message should be shown to the user, the input should be ignored just like the first code.