How to add number Validation on textbox in JS (JS में टेक्स्टबॉक्स पर संख्या सत्यापन कैसे जोड़ें)-
In this example, Number validation in Javascript “onkeypress” event to accept Number only (इस उदाहरण में, जावास्क्रिप्ट में संख्या सत्यापन “onkeypress” ईवेंट केवल संख्या स्वीकार करने के लिए).

- The onkeypress=”return onlyNumberAccept(event,this);” function called in text box on onkeypress event (onkeypress = “केवल NumberAccept (event, this) लौटाएं” फ़ंक्शन को onkeypress ईवेंट पर टेक्स्ट बॉक्स में कॉल किया जाता है).
- No jQuery library required (किसी jQuery लाइब्रेरी की आवश्यकता नहीं होती है).
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function onlyNumberAccept(e, t) {
try {
if (window.event) { var charCode = window.event.keyCode; }
else if (e) { var charCode = e.which; }
else { return true; }
if ((charCode < 65 || charCode > 90) && (charCode < 97 || charCode > 123) && charCode != 32 && charCode != 8 && charCode != 46) {
return false;
}
return true;
}
catch (err) { alert(err.Description); }
}
</script>
</head>
<body>
Mobile No. : <input type="text" maxlength="10" name="mobile_no" id="mobile_no" onkeypress="return onlyNumberAccept(event,this);">
</body>
</html>More validations … Click here …
Number Validation on textbox in JS onkeypress
Tags: How to add Number Validation on textbox, Number Validation for Textbox in jQuery, Number Validation in JavaScript, Text box to only accept numbers
