0
我顯示了註冊表單的錯誤消息/警報,它指向具有錯誤的輸入。表單驗證 - 專注於「錯誤」輸入
我也想關注這個錯誤輸入。
但是,我的代碼目前主要集中在最後一次輸入?
繼承人鏈接。重新創建,只需點擊寄存器而不填寫任何內容。錯誤顯示爲第一個div ...但着重於最後一個。
我當前的代碼:
$('#register-btn').on('click', checkEmpty);
function checkEmpty(){
var emptyDiv = $('.add-listing-input').filter(function() {
return $(this).val() == "";
});
if(emptyDiv.length > 0){
var theTop = emptyDiv.position();
var theBottom = theTop.top + emptyDiv.height() +25;
var theText = emptyDiv.attr('id');
$('#register-errors').css('top',theBottom+'px').show();
$('#error-text').text('Your '+theText+' is missing, please fill in');
emptyDiv.focus();
emptyDiv.on('keydown', function(){
$('#register-errors').hide();
$('#error-text').text('');
});
}else{
$('#register-errors').hide();
$('#error-text').text('');
checkEmails()
}
}
感謝,簡單好用 – rpsep2 2013-02-24 20:56:57