开发者

How to assign a jQuery Validation rule when I can't edit the class of my input?

I'm trying to understand how I can specify an inline validation rule, such as "required," for a parent element of the input element. So for example, currently the plugin will validate the name field if it has a "required" class:

<input name="email" class="required">

But my code only allows me to add that into the parent element

<li class="required">
 开发者_运维问答  <input name="email">

Is there a way to make validate look for the required class of the parent element instead?


Try:

$("li.required input").rules("add", {
    required: true
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜