var limit = 10;
$(document).ready(function(){
$('textarea').keypress(function()
{
return $(this).val().length < limit;
});
$('textarea').keyup(function(){
var text = $(this).val();
if(text.length > limit){
$(this).val(text.substr(0,limit));
}
})
});
Actually the best option perhaps would be using this jquery plugin: http://jqueryvalidation.org/
No comments:
Post a Comment