0
我似乎无法检查输入字段是否为空且需要以及是否警告用户。我目前正在工作,无需查看是否需要输入字段,问题是当非必填字段为空时弹出警报。无法验证输入字段是否为空并且是必需的
下面是代码:
$('.close-and-show-next').click(function() {
var empty = $(this).parent().find("input:visible").filter(function() {
return this.value === "";
});
if(empty.length && empty.closest('span').hasClass('required')) {
//At least one input is empty
$(this).parent().parent().find('.numberlabel').css('background-color','#FF0000');
alert('One or more fields have been left blank. Please press EDIT to correct before pressing continue.');
}
});
这里是小提琴:http://jsfiddle.net/joseph_a_garcia/uuVjy/1/