function chktext(oj) {

  if (!oj.value) {

    chktext[oj.name] = false  // 送信許可フラグ 1許可 2不許可
    alert("この項目は必ず入力してください")

    //対象エレメントの背景色をオレンジにする
    if(!!oj.style)oj.style.backgroundColor='#ffcc66'

  } else {

    chktext[oj.name] = true  

    //対象エレメントの背景色をオレンジにする
    if(!!oj.style)oj.style.backgroundColor='#ffffff'

  }

}

//--送信ボタンを押したときの全エレメントチェック
function chksubmit(oj){

//必須入力チェック
   err = 0;

   //未入力エレメントの背景色をオレンジにする
   if(!oj.name.value)    {oj.name.style.backgroundColor='#ffcc66'; err=1;} else {oj.name.style.backgroundColor='#fff';}
   if(!oj.mail.value)   {oj.mail.style.backgroundColor='#ffcc66';  err=1;}  else {oj.mail.style.backgroundColor='#fff';}
   if(!oj.mail2.value)   {oj.mail2.style.backgroundColor='#ffcc66';  err=1;}  else {oj.mail2.style.backgroundColor='#fff';}
   if(!oj.tel.value)     {oj.tel.style.backgroundColor='#ffcc66';  err=1;}  else {oj.tel.style.backgroundColor='#fff';}
   if(!oj.comment.value) {oj.comment.style.backgroundColor='#ffcc66'; err=1;}  else {oj.comment.style.backgroundColor='#fff';}

   if( err == 1) {
      alert('未入力項目(オレンジ色)へ入力してください')
      return false;
   }

//文字適合性チェック（メールアドレス）

  if (!oj.mail.value.match(/^[0-9a-z_\-.]+@[0-9a-z_\-.]+$/) ) {
     oj.mail.style.backgroundColor='#ffcc66';
     err = 1;
   }

  if (!oj.mail2.value.match(/^[0-9a-z_\-.]+@[0-9a-z_\-.]+$/) ) {
     oj.mail2.style.backgroundColor='#ffcc66';
     err = 1;
   }

  if (err == 1) {
    alert('emailアドレスの書式が正しくありません。');
    return false;
  }


  if (oj.mail.value != oj.mail2.value ) {
     oj.mail2.style.backgroundColor='#ffcc66';
     alert('2回入力したemailアドレスが一致しません。');
     return false;
   }


//文字適合性チェック（電話番号）
   oktel = '0123456789-';
   str = oj.tel.value;
   for (i=0;i<str.length;i++) {
     if (oktel.indexOf(str.charAt(i)) == -1) err++;
   }

   if (err!=0) {
     oj.tel.style.backgroundColor='#ffcc66';
     alert('電話番号の入力は半角英数字でお願いします。');
     return false;
   }

  return true;

}

