//フォームの内容チェック function formcheck() { // 変数宣言 var ErrMsg = ""; var ErrFlg = true; // 各オブジェクトの取得 var obj1 = document.getElementById("nm"); var obj2 = document.getElementById("kn"); var obj3 = document.getElementById("postno1"); var obj4 = document.getElementById("add1"); var obj5 = document.getElementById("add2"); var obj6 = document.getElementById("tel1"); var obj7 = document.getElementById("tel2"); var obj8 = document.getElementById("tel3"); var obj9 = document.getElementById("email11"); var obj10 = document.getElementById("email12"); var obj11 = document.getElementById("email21"); var obj12 = document.getElementById("email22"); var obj13 = document.getElementById("document"); var obj14 = document.getElementById("comment"); // エラー背景色のクリア obj1.style.backgroundColor='#FFFFFF'; obj2.style.backgroundColor='#FFFFFF'; obj3.style.backgroundColor='#FFFFFF'; obj4.style.backgroundColor='#FFFFFF'; obj5.style.backgroundColor='#FFFFFF'; obj6.style.backgroundColor='#FFFFFF'; obj7.style.backgroundColor='#FFFFFF'; obj8.style.backgroundColor='#FFFFFF'; obj9.style.backgroundColor='#FFFFFF'; obj10.style.backgroundColor='#FFFFFF'; obj11.style.backgroundColor='#FFFFFF'; obj12.style.backgroundColor='#FFFFFF'; obj13.style.backgroundColor='#FFFFFF'; obj14.style.backgroundColor='#FFFFFF'; // 必須項目のチェック if ( obj1.value == "" ){ ErrMsg = "\nお名前(漢字)"; obj1.style.backgroundColor='#FFDAB9'; obj1.focus(); ErrFlg = false; } // if ( obj2.value == "" ){ // ErrMsg = ErrMsg + "\nお名前(カナ)"; // obj2.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj2.focus(); // ErrFlg = false; // } // } // if ( obj3.value == "" ){ // ErrMsg = ErrMsg + "\n郵便番号"; // obj3.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj3.focus(); // ErrFlg = false; // } // } // if ( obj4.value == "選択してください" ){ // ErrMsg = ErrMsg + "\nご住所(都道府県)"; // obj4.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj4.focus(); // ErrFlg = false; // } // } // if ( obj5.value == "" ){ // ErrMsg = ErrMsg + "\nご住所(市区町村)"; // obj5.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj5.focus(); // ErrFlg = false; // } // } if ( obj6.value == "" ){ ErrMsg = ErrMsg + "\n電話番号(市外局番)"; obj6.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj6.focus(); ErrFlg = false; } }else{ if(!(chkNum(obj6))){; ErrFlg = false; } } if ( obj7.value == "" ){ ErrMsg = ErrMsg + "\n電話番号(市内局番)"; obj7.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj7.focus(); ErrFlg = false; } }else{ if(!(chkNum(obj7))){; ErrFlg = false; } } if ( obj8.value == "" ){ ErrMsg = ErrMsg + "\n電話番号(加入者番号)"; obj8.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj8.focus(); ErrFlg = false; } }else{ if(!(chkNum(obj8))){; ErrFlg = false; } } if (obj9.value == ""){ ErrMsg = ErrMsg + "\nEメールアドレス(アカウント)"; obj9.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj9.focus(); ErrFlg = false; } } if (obj10.value == ""){ ErrMsg = ErrMsg + "\nEメールアドレス(ドメイン名)"; obj10.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj10.focus(); ErrFlg = false; } } if (obj11.value == ""){ ErrMsg = ErrMsg + "\nEメールアドレス(アカウント)再入力"; obj11.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj11.focus(); ErrFlg = false; } } if (obj12.value == ""){ ErrMsg = ErrMsg + "\nEメールアドレス(ドメイン名)再入力"; obj12.style.backgroundColor='#FFDAB9'; if (ErrFlg){ obj12.focus(); ErrFlg = false; } } // if ( obj13.value == "" ){ // ErrMsg = ErrMsg + "\n資料請求"; // obj13.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj13.focus(); // ErrFlg = false; // } // } // if ( obj14.value == "" ){ // ErrMsg = ErrMsg + "\nお問い合わせ内容"; // obj14.style.backgroundColor='#FFDAB9'; // if (ErrFlg){ // obj14.focus(); // ErrFlg = false; // } // } if (!ErrFlg){ if (ErrMsg){ alert (ErrMsg + "\n\nが未入力です。入力してください。"); return false; } }else{ // emailの確認チェック var Email = obj9.value + obj10.value; var ReEmail = obj11.value + obj12.value; if (Email != ReEmail){ alert ("Eメールアドレスが一致しません。"); obj11.style.backgroundColor='#FFDAB9'; obj12.style.backgroundColor='#FFDAB9'; obj11.focus(); return false; } } return true; } //メールアドレスチェック function isMailAddr( str ){ if( str.indexOf("@") == -1 ){ return(false); } if( str.indexOf(".") == -1 ){ return(false); } for( i = 0 ; i < str.length ; i ++ ){ var c = str.charAt( i ); if( ( "a" <= c && c <= "z" ) || ( "A" <= c && c <= "Z" ) || ( "0" <= c && c <= "9" ) || c == "."|| c == "@" || c == "-" || c == "_" ) { continue; }else{ return(false); } } return(true); } //数値チェック function chkNum(obj){ var num='0123456789-'; /* 数値としてOKなもの */ var tmp=new Array(); for(var i=0; i