I want to create TextField
it allows only numbers.For this I written the following code but it's not working.
script code:
function numberTextField(){
var keyAsciiValue=event.keyCode||event.which;
console.log(keyAsciiValue);
if (keyAsciiValue>=48&&keyAsciiValue<=57) {
console.log("This is Number");
return true;
}else{
console.log("This is Not a Number");
return false;
};
}
html code:
<input type="text" onkeyup="numberTextField()" placeholder="NoOfRows" id="fieldsCount2"/>
can anyone help me.
Thanks.