I would like to know how to accept only the number that should be entered in the input field from 1 to 9, and if it is entered, for example, 0, a warning message is displayed, sorry for the invalid number.
please check my function which i have done so far but not working .. thanks
<input name="number1" type="text" size="1" id="number1"onkeyup="doKeyUpValidation(this)/>
doKeyUpValidation(text){
var validationRegex = RegExp(/[-0-9]+/, "g");
if(!validationRegex.match(text.value)
{
alert('Please enter only numbers.');
}
source
share