MAXLENGTH文本区域不工作在IE [英] Maxlength for text area doesn't work in IE

查看:119
本文介绍了MAXLENGTH文本区域不工作在IE的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图限制一个textarea输入的字符数如下所示:

I am trying to limit the number of characters entered in a textarea as shown:

<div>
 @Html.TextAreaFor(x => x.StudentName, new { @maxlength = "1000" })
</div>

这工作正常在Firefox和Chrome,但maxlength属性并不在IE浏览器。我如何做到这一点?

This works fine in Firefox and Chrome but the maxlength attribute doesn't work in IE. How do I do that??

推荐答案

最大长度属性不是的 &LT; TextArea&GT; 在HTML 4.01。它是在HTML5定义虽然的,但我想没有按IE浏览器 ŧ实现它。为了让对面,你可以使用JavaScript所有的浏览器。这里是一个例子

The maxlength attribute is not standard for <textarea> in HTML 4.01. It is defined in HTML5 though but I guess IE doesn't implement it. To make it work across all browsers you could use javascript. Here's an example.

这篇关于MAXLENGTH文本区域不工作在IE的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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