如何设置TextArea的maxLength以使其适用于所有浏览器? [英] How to set the maxLength of a TextArea so that it works across all browsers?

查看:133
本文介绍了如何设置TextArea的maxLength以使其适用于所有浏览器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在textarea控件上写了下面的maxLength限制,它在IE 9.0中工作正常,但不适用于IE 8.0。

I wrote the below maxLength restriction on the textarea control and it works fine in IE 9.0 but doesn't work with IE 8.0.

<textarea name="commentString" rows="7" maxlength="2000">some data </textarea>

如何设置maxLength以使其适用于所有浏览器? JQuery有没有这方面的帮助方法?

How can I set the maxLength so that it works across all browsers? would JQuery have any helper method for this?

推荐答案

   $('textarea').keypress(function() {
  return $(this).val().length < 50;
});

这篇关于如何设置TextArea的maxLength以使其适用于所有浏览器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆