尝试搜索特定数量的类“.good”,如果没有找到禁用按钮,如果发现该数量删除禁用。不能完全到达那里并工作。
$("fieldset.first").children().find('.good')[4](function(){
// or maybe -- $('fieldset:first-of-type').children('.good).length !== 4?
$('.next').removeAttr('disabled');
}else{
$('.next').prop('disabled', true);
}
或者,如果有更好的方法,我会全神贯注。
更新
http://jsfiddle.net/darcher/aUKhN/27/
这是验证的工作方式:
<!-- when page loads -->
<div class="item"><input required></div>
<!-- if it doesn't validate -->
<div class="item bad">
<input required>
<div class="alert">why it isn't validating</div>
</div>
<!-- and if it does validate it changes to -->
<div class="item good"><input required></div>
添加了 HTML
<fieldset class="first">
<legend>Create your login credentials</legend>
<div class="item">
<label>
<span>Email Address</span>
<input type="email" name="username" placeholder="e.g. name@email.com" required>
</label>
<div class="tooltip help">
<span>?</span>
<div class="help-content">
<b></b>
<p>You will use your email address to login to your WiseBanyan account</p>
</div>
</div>
</div>
<div class="item">
<label>
<span>Confirm email</span>
<input type="email" name="confirmUsername" data-validate-linked="username" placeholder="e.g. name@email.com" autocomplete="off" required>
</label>
</div>
<div class="item">
<label>
<span>Password</span>
<input type="password" name="password" data-validate-length-range="8" minlength="8" autocomplete="off" required>
</label>
<div class="tooltip help">
<span>?</span>
<div class="help-content">
<b></b>
<p>Minimum of 8 characters.</p>
<p>Must contain at least one uppercase letter and one number or symbol.</p>
</div>
</div>
</div>
<div class="item">
<label>
<span>Confirm password</span>
<input type="password" name="confirmPassword" data-validate-length-range="8" minlength="8" data-validate-linked="password" required>
</label>
</div>
<div class="details">
<strong>Information</strong>
<p>Type in the login information you would like. Hover over the <span class="ques">?</span> for further information on restrictions.</p>
</div>
<input type="button" name="previous" class="previous action-button" value="Previous" disabled>
<input type="button" name="next" class="next action-button" value="Next">