function zipaddr_ownpm(){ //contactform7
const ver= "1.19";
const idc0= "zip,zip2,zip3,zip4,zip5,zip6" .split(',');
const idc1= "zip1,zip21,zip31,zip41,zip51,zip61".split(',');
const idc2= "pref,pref2,pref3,pref4,pref5,pref6".split(',');
const idc3= "city,city2,city3,city4,city5,city6".split(',');
const idc4= "area,area2,area3,area4,area5,area6".split(',');
const idc5= "addr,addr2,addr3,addr4,addr5,addr6".split(',');
const idt= idc0.concat(idc1,idc2,idc3,idc4,idc5);
const zip= idc0[0]; // id="zip" - id="zip1"
const pref=idc2[0]; // id="pref"
const city=idc3[0]; // id="city"
const area=idc4[0]; // id="area"
const addr=idc5[0]; // id="addr"
let xz1= idc1[0]; // id="zip1"
let xfs= "focus";
if( !document.getElementById(xz1) ) xz1= zipaddr_ownpm_namec(xz1,xz1);
if( !document.getElementById(xfs) ) xfs= zipaddr_ownpm_namec(xfs,xfs);
let pm= new Array(); // default
let dcnt= 0; // name="zip"のみは id="zip" を付加する(優先処理)
for( let ii=0;ii= 2 ) return pm;// 従来と同じ動き(互換性優先)
//未設定の場合、自動設定を試みます。(xxx-xxxxは除外する)
let szip= zipaddr_ownpm_ctrl("郵便番号");
let spref= zipaddr_ownpm_ctrl("都道府県");
let scity= zipaddr_ownpm_ctrl("市区町村");
let sarea= zipaddr_ownpm_ctrl("町域");
let saddr= zipaddr_ownpm_ctrl("番地");
if( szip =="" ) szip= zipaddr_ownpm_ctrl("〒");
if( scity=="" ) scity= zipaddr_ownpm_ctrl("市町村");
if( sarea=="" ) sarea= zipaddr_ownpm_ctrl("地域");
if( saddr=="" ) saddr= zipaddr_ownpm_ctrl("以降の住所");
if( saddr=="" ) saddr= zipaddr_ownpm_ctrl("ご住所");
if( scity == sarea || scity == saddr ) scity="";
if( sarea == saddr ) sarea="";
//
const xzp= zipaddr_ownpm_namec(szip, zip );
const xpf= zipaddr_ownpm_namec(spref,pref);
const xcy= zipaddr_ownpm_namec(scity,city);
const xar= zipaddr_ownpm_namec(sarea,area);
const xad= zipaddr_ownpm_namec(saddr,addr); //Set
pm[1]= {"zip":xzp, "zip1":xz1, "pref":xpf, "city":xcy, "area":xar, "addr":xad, "focus":xfs};
return pm;
}
function zipaddr_ownpm_ctrl(uban){ let ans="";
const ptrn= new RegExp(uban); //郵便番号
ans= zipaddr_ownpm_look("p", ptrn);
if( ans=="" ) ans= zipaddr_ownpm_look("tr", ptrn);
if( ans=="" ) ans= zipaddr_ownpm_look("label",ptrn);
return ans;
}
function zipaddr_ownpm_look(tag,ptrn){ let ans="";
const elm= document.getElementsByTagName(tag);//label
for( let ii=0;ii郵便番号
if( dat.match(ptrn) ){
let msg= dat.match(/ name="(.*)"/i); //