js通用的登錄驗證

/* 試用 Javascript來實現通用的登陸驗證功能 *實現簡單 *代碼少 適用於簡單的JSP頁面管理*    * */
<%@ page language="java" contentType="text/html; charset=GBK"
    pageEncoding="GBK"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" " http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <script type="text/javascript"> function checkform(myform){  for(i=0;i<myform.length;i++){   if(myform.elements[i].value==""){    alert(myform.elements[i].title+"不能爲空!");    myform.elements[i].focus();    return false;   }  } } </script> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Insert title here</title> </head> <body> <form action="" name="form1" method="post" onSubmit="return checkform(form1)"> <table>  <tr>   <td>用戶名:<input name="name" title="用戶名" type="text"></td>   <td>密&nbsp;碼:<input name="pwd" title="密碼" type="password"></td>  </tr>  <tr>   <td colspan="2">郵&nbsp;&nbsp;&nbsp;箱<input name="email" title="郵箱" type="text" ></td>  </tr>  <tr>   <td><input type="submit" name="Submit" value="提交"></td>   <td><input type="reset" name="Reset" value="重置"></td>  </tr> </table> </form> </body> </html>
相關文章
相關標籤/搜索