jquery adds maxlength for textarea
The MaxLength property is not supported by default textarea.
KeyUp events via jquery:
The jquery code is as follows:
Copy Code code as follows:
<script type= "Text/javascript" >
$ (function () {
IE can also use textarea
$ ("textarea[maxlength]"). KeyUp (function () {
var area=$ (this);
var max=parseint (area.attr ("MaxLength"), 10); Gets the value of the MaxLength
if (max>0) {
The text length of the IF (Area.val (). Length>max) {//textarea is greater than maxlength
Area.val (Area.val (). substr (0,max)); Truncate text textarea of a value
}
}
});
Copied character handling issues
$ ("textarea[maxlength]"). blur (function () {
var area=$ (this);
var max=parseint (area.attr ("MaxLength"), 10); Gets the value of the MaxLength
if (max>0) {
The text length of the IF (Area.val (). Length>max) {//textarea is greater than maxlength
Area.val (Area.val (). substr (0,max)); Truncate text textarea of a value
}
}
});
});
</script>
Html:
Copy Code code as follows:
<textarea style=; width:300px "height:60px" maxlength= Textarea>