jason_kelly
06-29-2012, 03:42 PM
Hello,
I was wondering if it was possible to get the help of an expert here to help me with the following.
I have the following function below that does real time number checking, however, id like to modify the coding such that it takes into account that the the number entered into the textbox cannot start off as a 0, if its a zero, the function will automatically enter is as a "1"
I was thinking that regex might be really usefull here, but I dont even know where to start.
function onlyNumbers(evt) {
var e = event || evt; // for trans-browser compatibility
var charCode = e.which || e.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false }
return true;
}
<input
style="padding-left: 4px; font-family: arial; font-size: 9pt; width: 35px; height: 15px; border: none"
type="text"
id="row"
maxlength="4"
onkeypress= "return onlyNumbers();"
>
I was wondering if it was possible to get the help of an expert here to help me with the following.
I have the following function below that does real time number checking, however, id like to modify the coding such that it takes into account that the the number entered into the textbox cannot start off as a 0, if its a zero, the function will automatically enter is as a "1"
I was thinking that regex might be really usefull here, but I dont even know where to start.
function onlyNumbers(evt) {
var e = event || evt; // for trans-browser compatibility
var charCode = e.which || e.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) { return false }
return true;
}
<input
style="padding-left: 4px; font-family: arial; font-size: 9pt; width: 35px; height: 15px; border: none"
type="text"
id="row"
maxlength="4"
onkeypress= "return onlyNumbers();"
>