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
});
精彩评论