Alphabets Validation on Textbox in jQuery: jQuery में टेक्स्टबॉक्स पर अक्षर सत्यापन

Alphabets Validation on Textbox in jQuery

In this example, alphabet validation in jQuery “onkeypress” event by TextBox id to accept alphabets only. (इस उदाहरण में, केवल अक्षर स्वीकार करने के लिए TextBox id द्वारा jQuery “onkeypress” इवेंट में अक्षर सत्यापन)

Alphabets Validation on textbox in JS onkeypress

Steps –

  • First add jquery.min.js library in header section of PHP file. (सबसे पहले PHP फ़ाइल के हेडर सेक्शन में jquery.min.js लाइब्रेरी जोड़ें)
  • Call jQuery function on onkeypress event by id of TextBox as showing in bellow code (नीचे दिए गए कोड में दिखाए अनुसार TextBox की आईडी द्वारा onkeypress इवेंट पर jQuery फ़ंक्शन को कॉल करें) –
<!DOCTYPE html>
<html>
    <head>
		<script src="https://codeloveguru.com/master-library/js/jquery.min.js"></script>
        
       <script type="text/javascript">
       $(document).ready(function () {
	     $("#studentname").keypress(function(e) {
		   var key = e.keyCode;
		   if (key >= 48 && key <= 57) {
			     e.preventDefault();
		   }
	    });
     });	
</script>
	</head>
	<body>
		<input type="text" name="studentname" id="studentname">		
	</body>
</html>

Alphabets Validation on textbox in JS onkeypress

Alphabets Validation on textbox in jQuery

Tags: Alphabets Validation in jQuery, Alphabets Validation on TextBox in jQuery, How to allow only alphabets in textbox using Jquery, Javascript Validation to allow only Letters

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *