jQuery Validate插件:输入与textarea [英] jQuery Validate plugin: input vs. textarea
问题描述
我想知道为什么jQuery Validate插件的默认处理< input>
与< textarea>
。在下面的演示中,请注意 required
类需要< input>
但不是< textarea>
。
I'm wondering why there is a difference in jQuery Validate plugin's default handling of <input>
vs. <textarea>
. In the demo below, notice that the required
class makes the <input>
required but not the <textarea>
.
<form>
<input class='required' />
<textarea class='required' ></textarea>
<button value='submit'>submit</button>
</form>
$('form').validate();
http://jsfiddle.net/trpeters1/BrCzA/
推荐答案
它绝对无关输入
vs。 textarea
。
参见:< a href =http://jsfiddle.net/ZAaPu/2/> http://jsfiddle.net/ZAaPu/2/
这是失败,因为每个输入
必须具有唯一的名称
属性才能使此插件正常工作正常。 请参阅常规指南的标记建议部分。否则,只验证第一个元素,忽略所有其他元素。
It's failing because each input
must have a unique name
attribute in order for this plugin to work properly. See the "Markup Recommendations" section of the "General Guidelines". Otherwise, only the very first element is validated and all others are ignored.
<form>
<input name="thename" class='required' />
<textarea name="another" class='required'></textarea>
<button value='submit'>submit</button>
</form>
工作演示: http://jsfiddle.net/ZAaPu/
这篇关于jQuery Validate插件:输入与textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!