2
다음 코드는 계속 IE8에서 오류를 던지고 있습니다.IE8에서만 자바 스크립트 오류가 발생했습니다.
항상 모든 필드가 채워지지만 경고가 항상 나타납니다. 이것은 알려진 문제입니까?
if(errors == 0) {
return true;
} else {
alert("Please complete all (*) marked fields");
return false;
}
전체 코드 :
$(function(){
$("#d2b").click(function(){
$("#first_name").val($("#bill_fname").val());
$("#last_name").val($("#bill_lname").val());
$("#del_address_1").val($("#bill_address_1").val());
$("#del_address_2").val($("#bill_address_2").val());
$("#del_city").val($("#bill_city").val());
$("#del_county").val($("#bill_county").val());
$("#del_postcode").val($("#bill_postcode").val());
return false;
});
$("#gpn").submit(function(){
errors = 0;
$("#gpn input[type='text']").each(function(){
var nm = $(this).attr('name');
if(nm == 'bill_address_2' || nm == 'del_address_2' || nm == 'groupon_barcode') {
;
} else {
if($(this).attr('name') == 'code') {
var gpncode = $(this).val();
if(gpncode.length != 10) {
errors++;
alert("Uh Oh");
return;
}
var str = gpncode;
var patt=/[0-9A-Za-z]{10}/g;
var result=patt.test(str);
if(!result) {
errors++;
alert("this should be longer");
}
return;
}
if($(this).val() == '') {
errors++;
}
}
});
if(errors == 0) {
return true;
} else {
alert("Please complete all (*) marked fields");
return false;
}
});
});
당신이 === 0 –
위의 편집을 게시 오류를 시도 숫자로 오류를 비교하는 경우)들 덕분에 – meohmy