<div class="codetitle"> <span><a style="CURSOR: pointer" data="63749" class="copybut" id="copybut63749" onclick="doCopy('code63749')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code63749"> <br>//检查表单元素是否为空 <br>function check(Form) <br>{ <br>for (i=0;i<form.length>if(Form.elements[i].value == "") <br>{ <br>//Form的属性elements的首字e要小写 <br>alert(Form.elements[i].name + "不能为空!"); <br>Form.elements[i].focus(); <br>//指定表单元素获得焦点 <br>return; <br>} <br>} <br>Form.submit(); <br>} <br>调用 <br><form name="form1" method="post" action=""> <br>留 言 人:<input type="text" name="mname" size="20"> <br>留言主题:<input type="text" name="mtext" size="66"> <br>留言内容:<textarea name="mnote" cols="64" rows="10" class="wenbenkuang"></textarea> <br><input name="Button" type="button" class="btn_grey" value="提交">onClick="check(form1)"> <br><input name="Submit2" type="reset" class="btn_grey" value="重置"> <br> </form> <br></form.length> </div>