<HTML>
<HEAD>
<TITLE>Form checker</TITLE>
<Script TYPE="text/javascript">
<!--
if (navigator.appVersion.charAt(0)>="4") {
function MakeArray(n){
this.length=n;
}
//alert message
var error = new MakeArray(3);
error[1] = "お名前を記入してください。";
error[2] = "Emailアドレスを正しく記入してください。";
error[3] = "電話番号は半角数字でご記入ください。";
error[5] = "質問1にチェックしてください。";
error[6] = "質問2を選んでください。";
var i,n;
//show the alert
function check_all(){
if (check1(document.myForm.name.value) == false){alert(error[1]);}
else if (check1(document.myForm.mail.value) == false){alert(error[2]);}
else if (check2(document.myForm.mail.value)==false){alert(error[2]);}
else if (check3(document.myForm.tel.value) == false){alert(error[3]);}
else if (check4() != true){alert(error[5]);}
else if (check5() == false){alert(error[6]);}
else {document.myForm.submit();}
}
//no message
function check1(strTarget){
if(strTarget == ""){return false;}
else{return true;}
}
//mail address check
function check2(strTarget){
var transTarget;
var checkStr = new String("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-@._");
transTarget = strTarget.replace(/ /g,"");
for(i=0;i<transTarget.length;i++){
if(checkStr.indexOf(transTarget.charAt(i),0)==-1){
return false; }
}
if (transTarget.indexOf("@") == -1) {
return false; }
if (transTarget.indexOf(".") == -1) {
return false; }
else {return true;}
}
//number check
function check3(strTarget){
var transTarget;
var checkStr = new String("0123456789-");
transTarget = strTarget.replace(/ /g,"");
for(i=0;i<transTarget.length;i++){
if(checkStr.indexOf(transTarget.charAt(i),0)==-1){
return false; }
else {return true;}
}
}
//Question1 check
function check4() {
for (i=0; i < 4; i++){
if (document.myForm.Q1[i].checked == true) {return true;}
}
}
//Question2 check
function check5() {
if (document.myForm.Q2.options[0].selected == true) {return false;}
}
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<FORM ACTION="***.cgi" METHOD="get" NAME="myForm">
※すべての項目にご記入をお願いします。 <TABLE BORDER="0" CELLPADDING="1" CELLSPACING="1" BGCOLOR="#CCCCCC"> <TR>
<TD BGCOLOR="#FFFFFF">NAME</TD>
<TD BGCOLOR="#FFFFFF"><INPUT TYPE="text" SIZE="20" NAME="name"></TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF">Email</TD>
<TD BGCOLOR="#FFFFFF"><INPUT TYPE="text" SIZE="20" NAME="mail"></TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF">Telephon</TD>
<TD BGCOLOR="#FFFFFF"><INPUT TYPE="text" SIZE="20" NAME="tel"></TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF">Question1</TD>
<TD BGCOLOR="#FFFFFF"><input type="radio" name="Q1" value="q1">
項目1/
<input type="radio" name="Q1" value="q2">
項目2/
<input type="radio" name="Q1" value="q3">
項目3/
<input type="radio" name="Q1" value="q4">
項目4 </TD>
</TR>
<TR>
<TD BGCOLOR="#FFFFFF">Question2</TD>
<TD COLSPAN="2" BGCOLOR=""EEEEEE">
<SELECT NAME="Q2">
<OPTION VALUE="">選択してください</OPTION>
<OPTION VALUE="s1">選択1</OPTION>
<OPTION VALUE="s2">選択2</OPTION>
<OPTION VALUE="s3">選択3</OPTION>
</SELECT>
</TD>
</TR>
</TABLE>
</FORM>
</BODY>
</HTML>
|