当前位置: 代码迷 >> Web前端 >> validate步骤
  详细解决方案

validate步骤

热度:350   发布时间:2012-07-01 13:15:00.0
validate方法

$("#addUserForm").validate({

? ? ? ? ? ? ?errorPlacement: function(label, element) {

? ? ? ? ? ? ? ? ?if (element.is(":radio") ){

? ? ? ? ? ? ? ? ? ? ?element.parent().next().next().html(label);

? ? ? ? ? ? ? ? ?}else{

? ? ? ? ? ? ? ? ? ? ?element.parent().children("span").html(label);

? ? ? ? ? ? ? ? ?}

? ? ? ? ? ? ?},

? ? ? ? ? ? ?success: function(label) {

? ? ? ? ? ? ? ? ?label.addClass("checked").removeClass("error");

? ? ? ? ? ? ?},

? ? ? ? ? ? ?rules:{

? ? ? ? ? ? loginName:{

? ? ? ? ? ? required: true

? ? ? ? ? ? },

? ? ? ? ? ? ? ? ?password:{

? ? ? ? ? ? required: true

? ? ? ? ? ? },

? ? ? ? ? ? confirmPassword:{

? ? ? ? ? ? required: true,

? ? ? ? ? ? equalTo:"#password"

? ? ? ? ? ? },

? ? ? ? ? ? name:{

? ? ? ? ? ? ? ? ? ? ?required: true

? ? ? ? ? ? ? ? ? ? ?/* rangelength: [ 3, 20 ],

? ? ? ? ? ? ? ? ? ? ?remote:"/userNameCheck.htm" */

? ? ? ? ? ? ? ? ?},

? ? ? ? ? ? ? ? ?email:{

? ? ? ? ? ? ? ? required: true,

? ? ? ? ? ? ? ? email:true

? ? ? ? ? ? ? ? ?},

? ? ? ? ? ? ? ? ?"user.testdouble":{

? ? ? ? ? ? ? ? required: true,

range: [13, 23]

? ? ? ? ? ? ? ? ?}

? ? ? ? ? ? ?},

? ? ? ? ? ? ?messages: {

? ? ? ? ? ? name: {

? ? ? ? ? ? ? ? ? ? // required: "用户名不能为空"

? ? ? ? ? ? ? ? ? ? /* ?rangelength: "用户名长度为{0}到{1}个字符",

? ? ? ? ? ? ? ? ? ? ?remote:"该用户已经存在,请换别的用户名" */

},

confirmPassword:{

equalTo:"两次输入密码不一致!"

}

? ? ? ? ? ? ?},

? ? ? ? ? ? ?submitHandler: function(form) {

jQuery(form).ajaxSubmit({?

? ? ? ?type : "post", ?

? ? ? ?dataType : "json", ?

? ? ? ?url : "${ctx}/system/addUser.action", ?

? ? ? ?data : {"operate" : "addUser"}, ?

? ? ? ?cache : "false", ?

? ? ? ?beforeSubmit : beforeCallBack, ?

? ? ? ?success : successCallBack, ?

? ? ? ?error : errorCallBack

});

}

? ? ? ? ?});

});

  相关解决方案