Code function validate Input number in textbox only.
html
js function
html
- <input type="text" id="test_id" name="test" value="" oninput="validateInput(event)">
js function
- function validateInput(event) {
- var input = event.target.value;
- if (!/^[0123456789 ]*$/.test(input)) {
- event.target.value = input.replace(/[^0123456789 ]/g, '');
- }
- }
No comments:
Post a Comment