javascript 판단 폼 이 비어 있 으 면 안 됩 니 다!

2336 단어 JavaScript
<div class="biaodan">
        	<h3>(  <font color="red">*</font>    )</h3>
            <div class="bdnr">
			<form name="contactForm" method="post" action="/mail.php"  onsubmit="return check()" >
            	<table width="500" border="0" cellspacing="0" cellpadding="0" align="center">
                  <tr>
                    <td align="right">   <font color="red">*</font></td>
                    <td><input name="q1" type="text" /></td>
                  </tr>
                  <tr>
                    <td align="right">    <font color="red">*</font></td>
                    <td><input name="q2" type="text" /></td>
                  </tr>
				  <tr>
                    <td align="right">    <font color="red">*</font></td>
                    <td><input name="q3" type="text" /></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td><input name="submit" type="submit" value="    " class="icon" ></td>
                  </tr>
                </table>
			</form>
            </div>
        </div>
<!--by:xue-->
		<script language="javascript">
function check()
{
if(document.contactForm.q1.value=="")
{
alert("       !");
this.contactForm.q1.focus();
return false;
}
else if(document.contactForm.q2.value=="")
{
alert("      !");
this.contactForm.q2.focus();
return false;
}
else if(document.contactForm.q3.value=="")
{
alert("      !");
this.contactForm.q3.focus();
return false;
}
else contactForm.submit();
}
</script>

좋은 웹페이지 즐겨찾기