Ajax实现登陆并友好提示错误信息
2013-07-01 21:03
309 查看
记录一个有用的js代码,其效果是点击提交表单后动态提示信息。
可以修改返回成功部分完成页面的跳转。
可以修改返回成功部分完成页面的跳转。
function validateForm() { return $("#form1").validate({ rules: { userName: { required: true, maxlength: 10 }, password: { required: true, maxlength: 10 } }, messages: { userName: { required: "不能为空", maxlength: jQuery.format("不能超过{0}个字符") }, password: { required: "不能为空", maxlength: jQuery.format("不能超过{0}个字符") } } }).form(); }; function doSubmit() { console.log("click!"); if (validateForm()) { console.log("validate success!"); var usernama = $("#userName").val(); var password = $("#password").val(); console.log("username:" + usernama); console.log("password:" + password); var data = { 'userName': usernama, 'password': password }; $.ajax({ type: "POST", data: JSON.stringify(data), contentType: "application/json; charset=utf-8", dataType: "json", success: function (data) { console.log(data); if (this.result == "OK") { console.log("respon success"); //do some thing! } else { $("#loginInfor").css({ "display": "block", "opacity": "1" }); $("#loginInfor").animate({ opacity: 0 }, 2000); $("#loginInfor").html("用户名密码错误"); console.log("respon success, but the password is worry!"); } }, error: function () { console.log("respon error"); } }); } };
相关文章推荐
- tp3.2.3下用ajax做一个登陆页面,为什么没有登录错误提示信息?
- ajax提交等待服务器响应友好提示信息的实现
- Mybatis错误笔记之:实现登陆操作提示parameter not found
- 用AjaxPro无刷新实现站内短信息实时提示功能
- 登陆输入为空或错误时的提示信息
- django项目培训站-17-用户登陆-自定义用户验证方式-错误提示信息传前端
- 关闭MOSS的友好提示 ,显示详细的错误信息ZZ
- 一个流行且实用的JS表单验证提示,演示了怎么自定义错误信息的显示方式,同时通过写FormValid.showError类方法来实现错误显示方式自定义: errMsg 是一个错误消息的数组,这样方便自定
- jquery 实现Ajax--[转]JQuery.Ajax之错误调试帮助信息
- 【Discuz】-QQ互联登陆提示错误信息:Unknown column 'conuintoken' in 'field list'
- asp.net mvc当出现错误时如何实现友好错误提示
- 利用java filter 实现业务异常拦截 跳转到错误信息提示页面
- Ajax实现收藏论坛版块功能,并异步返回提示信息
- AJAX表单错误和提示信息乱码
- ASP.NET AJAX控件实现信息提示窗口
- 我的ASP.NET AJAX控件——PopupNotificationExtender:实现OWA或Messenger样式的信息提示窗口
- 我的ASP.NET AJAX控件——PopupNotificationExtender:实现OWA或Messenger样式的信息提示窗口
- 创建ASP.NET AJAX客户端组件实现验证控件的toolTip式错误提示
- 一个实现ajax之后既可以刷新又可以让提示信息延长的js实现方法
- Spring MVC 下,不使用AJAX 登录时的错误提示的实现