日期:2014-05-17 浏览次数:20785 次
var person={ email:null, password:null, name:null }; /** 检查用户email是否存在,并且是否有空值*/ var checkRegisterOk=function(){ var isOk=true; //获取值的 dwr.util.getValues(person); $.each(person,function(key,value){ if(value==null){ $('#'+key).after("<p>"+key+"不能为空</p>"); isOK=false; return ; } } ); return isOK; };
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %> <%@taglib prefix="s" uri="/struts-tags" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <s:form method="post" onsubmit="return checkRegisterOk();"> <div class="register" align="center"> <label>邮箱</label> <input id="email" name="email" type="text" maxlength="60" tabindex="1" value=""/><br/> <label>密码</label> <input id="password" name="password" type="text" maxlength="60" tabindex="1" value=""/><br/> <label>名字</label> <input id="name" name="name" type="text" maxlength="60" tabindex="1" value=""/><br/> </div> <div align="center"> <label>个人描述(可选)</label> <input id="description" name="description" type="text" maxlength="60" tabindex="1" value=""/><br/> <button type="submit" >注册</button> <br/> </div> </s:form>