日期:2014-05-16  浏览次数:20332 次

action中用对象接收form中提交数据怎样用jquery-validate验证?
HTML code

    $().ready(function() {
$("#signupForm").validate({
        rules: {
   user.u=firstname: "required",
   email: {
    required: true,
    email: true
   },
   user.password: {
    required: true,
    minlength: 5
   },
   user.confirm_password: {
    required: true,
    minlength: 5,
    equalTo: "#password"
   }
},
        messages: {
   user.firstname: "请输入姓名",
   email: {
    required: "请输入Email地址",
    email: "请输入正确的email地址"
   },
   user.password: {
    required: "请输入密码",
    minlength: jQuery.format("密码不能小于{0}个字符")
   },
   user.confirm_password: {
    required: "请输入确认密码",
    minlength: "确认密码不能小于5个字符",
    equalTo: "两次输入密码不一致不一致"
   }
}
    });
});

<form id="signupForm" method="get" action="">
    <p>
        <label for="firstname">Firstname</label>
        <input id="firstname" name="user.firstname" />
    </p>
<p>
<label for="email">E-Mail</label>
<input id="email" name="user.email" />
</p>
<p>
<label for="password">Password</label>
<input id="password" name="user.password" type="password" />
</p>
<p>
<label for="confirm_password">确认密码</label>
<input id="confirm_password" name="user.confirm_password" type="password" />
</p>
    <p>
        <input class="submit" type="submit" value="Submit"/>
    </p>
</form>





采用对象.属性的方式 就不能触发验证了。如果我要在action中用一个user对象接受这个表单的提交数据。应该怎么用jquery-validate作验证?

------解决方案--------------------
http://blog.csdn.net/ddff2004/archive/2009/09/03/4515199.aspx
------解决方案--------------------
貌似问题就出在.上啊
用下划线也OK滴哟