首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript判断表单不能为空

2013-03-01 
javascript判断表单不能为空!div methodpost action/mail.phponsubmitreturn check() table w

javascript判断表单不能为空!

<div 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="提交申请" ></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>

热点排行
Bad Request.