1. Copy The Below Code to Page Function and Global Variable Declaration.
function validateNumber(event) {
var keyCode = event.keyCode;
var excludedKeys = [8, 37, 39, 46];
if (!((keyCode >= 48 && keyCode <= 57) ||
(keyCode >= 96 && keyCode <= 105) ||
(excludedKeys.includes(keyCode)))) {
console.log("alphabets are not allowed");
event.preventDefault();
}
console.log("keycode: " + keyCode);
}
2. And Copy the below function Calling on Item Custom Attribute.
onkeydown="return validateNumber(event)";
No comments:
Post a Comment