0
使用引導輸入驗證類和jQuery,有沒有更好的方法爲馬上驗證輸入用戶輸入的東西比此之後:引導輸入驗證與jQuery
CONTACT_INPUT_EMAIL.blur(function(event) {
if (CONTACT_INPUT_EMAIL.is(':valid')) {
CONTACT_INPUT_EMAIL_CONTAINER.addClass('has-success has-feedback');
CONTACT_INPUT_EMAIL_GLYPHICON.addClass('glyphicon-ok');
// if previous input was invalid
CONTACT_INPUT_EMAIL_GLYPHICON.removeClass('glyphicon-remove');
CONTACT_INPUT_EMAIL_CONTAINER.removeClass('has-error');
}
else {
CONTACT_INPUT_EMAIL_CONTAINER.addClass('has-error has-feedback');
CONTACT_INPUT_EMAIL_GLYPHICON.addClass('glyphicon-remove');
// if previous input was valid
CONTACT_INPUT_EMAIL_GLYPHICON.removeClass('glyphicon-ok');
CONTACT_INPUT_EMAIL_CONTAINER.removeClass('has-success');
}
CONTACT_INPUT_EMAIL_GLYPHICON.removeClass('invisible');
});
CONTACT_MODAL.on('hidden.bs.modal', function() {
CONTACT_INPUT_EMAIL_CONTAINER.removeClass('has-feedback has-success has-error');
CONTACT_INPUT_EMAIL.val('');
CONTACT_INPUT_EMAIL_GLYPHICON.addClass('invisible');
});
所有這些代碼僅僅是一個單一的電子郵件輸入在我看來很麻煩......