日期:2014-05-16 浏览次数:20360 次
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script type="text/javascript" language="javascript"> function FunCheckCosts() { //不为空的文本框的ID if (!CheckFields("name,pwd")) { alert("信息必须填写完整!"); return false; } } function CheckFields(txtChecks) { var oArray = txtChecks.split(","); for (var i=0;i<oArray.length;i++) { if (document.getElementById(oArray[i]).value.replace(/\s/g,"") == "") { try { document.getElementById(oArray[i]).focus(); } catch (e) {} event.returnValue = false; return false; } } return true; } </script> </head> <body> <form action="" method="post" onsubmit="return FunCheckCosts()"> <input type="text" name="name" id="name" /> <input type="text" name="pwd" id="pwd" /> <input type="submit" name="button" value="提交" /> </form> </body> </html>