google codeで公開されている郵便番号自動入力
Google コードで公開されているajaxzip3.js を読み込むだけ
(郵便番号のデータをサーバに置く必要がない)
headへの記述
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>郵便番号を入力すると住所を自動入力できる「ajaxzip3」が超便利</title> <script src="http://ajaxzip3.googlecode.com/svn/trunk/ajaxzip3/ajaxzip3.js" charset="UTF-8"></script>
httpsで読み込む
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>郵便番号を入力すると住所を自動入力できる「ajaxzip3」が超便利</title> <script src="https://ajaxzip3.googlecode.com/svn/trunk/ajaxzip3/ajaxzip3-https.js" charset="UTF-8"></script>
郵便番号を7桁のひと続きで入力する場合
<form> <fieldset>郵便番号:<input type="text" name="zip01" size="10"maxlength="8" onKeyUp="AjaxZip3.zip2addr(this,'','pref01','addr01');"></fieldset> <fieldset>住所1:<input type="text" name="pref01" size="20"></fieldset> <fieldset>住所2:<input type="text" name="addr01" size="60"></fieldset> </form>
郵便番号が3桁 + 4桁の2つに分かれている場合
<input type="text" name="zip21" size="4" maxlength="3"> - <input type="text" name="zip22" size="5" maxlength="4" onKeyUp="AjaxZip3.zip2addr('zip21','zip22','pref21','addr21','strt21');">
<input type="text" name="pref21" size="40">
<input type="text" name="addr21" size="40">
住所を都道府県市区町まで1行で入れる場合
<input type="text" name="zip11" size="10" maxlength="8" onKeyUp="AjaxZip3.zip2addr(this,'','addr11','addr11');"> <input type="text" name="addr11" size="60">