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