【发布时间】:2013-07-19 12:35:45
【问题描述】:
我有以下 javascript 代码来验证带有用户名和密码的简单登录表单 - 如果有影响,它是 asp.net 自定义验证器的客户端验证。
function userValidation(source, arguments) {
if (arguments.Value != "" && arguments.Value != "User name") {
if($(source).parents(".loginPanel").find(".errorAsterisk[style*='visible']").length==0) {
$(source).parents(".loginPanel").css({ "background-color": "" });
}
arguments.IsValid = true;
} else {
$(source).parents(".loginPanel").css({ "background-color": "#ECC8C8" });
arguments.IsValid = false;
}
}
function passwordValidation(source, arguments) {
var passVal = /^((?![<>]).){1,64}$/;
if (arguments.Value != "" && arguments.Value != "Password" && passVal.test(arguments.Value)) {
if($(source).parents(".loginPanel").find(".errorAsterisk[style*='visible']").length==0) {
$(source).parents(".loginPanel").css({ "background-color": "" });
}
arguments.IsValid = true;
} else {
$(source).parents(".loginPanel").css({ "background-color": "#ECC8C8" });
arguments.IsValid = false;
}
}
我还希望在用户成功填写表单时显示“正在加载”消息 - 这是我的代码...
$(".loginPanel").on("click", "input[id*='Login']", function() {
loadingPage2("", "Logging in...");
});
麻烦的是,即使页面无效,加载功能也会运行。
有什么想法可以包含它,以便它仅在 一切 有效的情况下运行?
谢谢
【问题讨论】:
标签: javascript jquery validation