0
我有一些字段的表單,並且還另一種形式相同的形式的內部, 我想驗證上部形式和分別內形式, 爲例如多發性形式標籤:驗證形式使用自舉formvalidators
<form name="upperFORM" ID="upperFORM" >
<div class="form-control-group">
<label class="control-label" for="email">Email Address</label>
<div class="controls">
<input type="text" class="input-xlarge" name="email" id="email">
</div>
</div>
<div class="form-control-group">
<label class="control-label" for="message">Your Address</label>
<div class="controls">
<textarea class="input-xlarge" name="address" id="address" rows="3"></textarea>
</div>
</div>
<form name="innerForm" id="innerForm" >
<div class="form-control-group">
<label class="control-label" for="name">Your Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="name" id="name">
</div>
</div>
<div class="form-control-group">
<label class="control-label" for="name">User Name</label>
<div class="controls">
<input type="text" class="input-xlarge" name="username" id="username">
</div>
</div>
</form>
</form>
jQuery驗證:
$('#upperFORM').validate({
rules: {
email: {
required: true,
required: true
},
address: {
minlength: 6,
required: true
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
element
.text('OK!').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
$('#innerForm').validate({
rules: {
name: {
required: true,
required: true
},
username: {
minlength: 6,
required: true
}
},
highlight: function (element) {
$(element).closest('.control-group').removeClass('success').addClass('error');
},
success: function (element) {
element
.text('OK!').addClass('valid')
.closest('.control-group').removeClass('error').addClass('success');
}
});
上面的代碼不能正常工作,請幫助