//郵便番号取得 function getAddress(){ var zip1 =document.getElementById('zip1').value; var zip2 =document.getElementById('zip2').value; var str = zip1 + zip2; var han = "0123456789"; var zen = "0123456789"; var zip=""; //半角に置換 for (i=0; i= 0) { c = han.charAt(n); } if(!c.match(/[^0-9]+/)){ zip += c; } } if( zip1.length =='3' && zip2.length == '4' ){ GetAddress(zip); } } //住所の取得 function GetAddress(zip) { var url = 'http://www.higawari.info/js/address.php'; var pars = 'zip=' + zip; var myAjax = new Ajax.Request(url, { method: 'get', parameters: pars, onComplete: AddressResponse }); } //住所の出力 function AddressResponse(req) { var data =eval(decodeURIComponent(req.responseText)); if (data[0].pref) { // data[0].town = data[0].town.replace(/(.*)/,''); data[0].town = data[0].town.replace(/(.*$/,''); data[0].town = data[0].town.replace(/以下に掲載がない場合/,''); document.getElementById('pref').value  = data[0].pref; document.getElementById('address').value = data[0].city + data[0].town; } }