提交form表单---修改密码 ajax、jQuery
<form id ="password" method="post"> <table > <tr> <td>原密码:</td> <td><input type="password" class="easyui-validatebox" required="required" name="oldPassw"/></td> </tr> <tr> <td>新密码:</td> <td><input type="password" class="easyui-validatebox" required="required" name="newPassw1"/></td> </tr> <tr> <td>确认密码:</td> <td><input type="password" class="easyui-validatebox" required="required" name="newPassw2"/></td> </tr> <tr> <td colspan="2" ><input type="reset" value="重置" style="margin-left: 50px" /> <input id="sub" type="button" value="提交" style="margin-left: 20px"></td> </tr> </table> </form>
jquery:
$(function() {
$("#sub").click(function(){ $("#password").form("submit",{ url:"xiuGaiPasswServlet", onSubmit: function(){ var s = $("#passsword").form("validate"); if(s) { return true; } else { $.messager.alert("提示","信息填写不完整","info"); return false; } }, success:function(data){ var data1 = eval("("+data+")"); if(data1.success){ $.messager.alert("提示","修改密码成功","info"); $("#xiugaimima").window("close"); } else { $.messager.alert("提示","修改失败","info"); } if(data1.success1){ $.messager.alert("提示","两次密码不一致","info"); } if(data1.success2){ $.messager.alert("提示","原始密码错误","info"); } } }); });
});
easyui-validatebox:验证框