Published
- 1 min read
javascript validate number only
The solution for this is noted below
javascript validate number only
Solution
function validateNumber(e) {
const pattern = /^[0-9]$/
return pattern.test(e.key)
}
Try other methods by searching on the site. That is if this doesn’t work