我遇到了两个函数和一个 if 语句的问题。我被告知功能go
并postcodeChange
没有定义。
我还被告知flag
在if flag == 1
.
知道我哪里出错了吗?谢谢你。
function postcodeChange(){
document.getElementById("goButton").onclick = distanceCheck;
}
function distanceCheck(){
var distance = document.getElementById("distance").value
var patt1=new RegExp("^[0-9]+(\.[0-9]{1})?$");
var out = patt1.exec(distance);
if (out == null) {
//distance is not a valid number
document.getElementById("distanceFlag").value = 1
}
else {
//distance is valid number
document.getElementById("distanceFlag").value = 0
}
function go(){
var flag = document.getElementById("distanceFlag").value
if flag == 1
{
alert("Distance is not valid- enter a number with no more than one decimal point");
}
else{
popSubmit('#fa Care Provider Search Go','','0');
}
}