0
에서 나는 사용자 정의 필드를 사용하고이 값을 반환하고 어떻게 든이 때문에 내부 함수의 부울 값을 반환하는 우편 번호 필드의 유효성을 검사 할 필요가 없습니다 검증 :페이스 북 등록 플러그인 + 내 페이스 북 등록 플러그인의 기능
geocoder.geocode({ address: address }, function (results, status) {
}
을
addExist 변수에 값을 반환 할 수 없으며 항상 '정의되지 않음'을 반환합니다. 누구든지 도와 줄 수 있습니까? 감사.
<fb:registration redirect_uri="http://localhost:40153/Account/RegisterDestination.aspx"
fields='[
{"name":"name"},
{"name":"gender"},
{"name":"email"},
{"name":"birthday"},
{"name":"password"},
{"name":"zip","description":"Postal Code","type":"text"}]'
onvalidate="validate"></fb:registration>
function validate(form) {
errors = {};
if (form.zip !== "") {
var addExist = calculateCoordinates(form.zip.toString());
// alert(addExist);
if (!addExist) {
errors.zip = "Cannot locate address";
}
}
return errors;
}
function calculateCoordinates(zip) {
var txtPostcode = zip;
// var address = txtAddress1.value + ', ';
// address += txtAddress2.value + ', ';
// address += txtTown.value + ', ';
var address = txtPostcode;
// address += txtCountry.value;
var geocoder;
geocoder = new google.maps.Geocoder();
geocoder.geocode({ address: address }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var location = results[0].geometry.location;
var litLatClientId = document.getElementById("<%=litLat %>");
var litLongClientId = document.getElementById("<%=litLong %>");
$("#" + litLatClientId).val(location.lat());
$("#" + litLongClientId).val(location.lng());
// Successfully reach here but the bool variable 'addExist' value gets an 'Undefined' value.
return true;
}
else
return false;
});
}