Textbox Max Length using JQuery | How to give Max Length to textbox field using JQuery or Javascript?

Textbox Max Length Setting

Using attr method we can give the maxlength property to the textbox. Please check below complete jquery example for more details. This is one of the good JQuery Interview Question.

<html>
<head>
<script type="text/javascript" 
src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
    $("#txtLengthValidation").attr('maxlength','6');
});
</script>
</head>
<body>
<input style="WIDTH: 275px" id="txtLengthValidation" name="realname" class="required" 
size="25" minlength="2" placeholder="First Name" >
<b>aspnettutorialonline.blogspot.com</b>
</body>
</html>


 
Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar