此函数在表单提交期间执行,在 Firefox 和 Chrome 中运行良好,但在 IE 中无法正常运行。我怀疑它是 indexOf,但我似乎找不到让它工作的方法。
function checkSuburbMatch(e) {
var theSuburb = document.getElementById('suburb').value;
var thePostcode = document.getElementById('postcode').value;
var arrayNeedle = theSuburb + " (" + thePostcode + ")";
if(suburbs.indexOf(arrayNeedle) != -1) {
alert("Suburb and Postcode match!");
return false;
} else {
alert("Suburb and Postcode do not match!");
return false;
}
}