Facebook登録プラグインでカスタムフィールドを使用していますが、この内部関数が原因で、ブール値を返すzipcodeフィールドを検証する必要があります。
geocoder.geocode({ address: address }, function (results, status) {
}
addExist変数に値を返すことができず、常に「Undefined」を返します。誰か助けてもらえますか?ありがとう。
<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;
});
}