<div class="form-group label-floating is-empty">
<label for="i2" class="control-label">Password</label>
<input confirm_password type="password" name="password" class="form-control" id="i2">
</div>
<div id="confirm_pwd_item" class="form-group label-floating is-empty">
<label for="i2" class="control-label">Confirm Password</label>
<input confirm_password type="password" name="password_confirmation" class="form-control" id="i2">
</div>
私の方法動的に入力
$('input[confirm_password]').each(function(){
$(this).bind('input propertychange',function(){
setTimeout(function(){
if($('input[name=password]').val() !== $('input[name=password_confirmation]').val()){
$("#confirm_pwd_item").addClass('has-error');
}
else{
$("#confirm_pwd_item").removeClass('has-error');
}
},100)
})
})
私はこのフレームワークを使い始めるよにCSSクラスを追加する方法。
パスワードと確認パスワードが等しくない場合は、入力にhas-error
を追加します。
しかし、これは良い方法ではありません。
ない場合のsetTimeout関数:
なぜこののsetTimeout()? – jonju