i have following javascript code validate simple login form user name , password - it's client validation of asp.net custom validator if makes difference.
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; } } i want "loading" message appear when user fills in form - here's code have that...
$(".loginpanel").on("click", "input[id*='login']", function() { loadingpage2("", "logging in..."); }); the trouble is, loading function runs if page not valid.
any ideas can include runs if everything valid?
thanks
without seing more code this:
var x = []; 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; x.push(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; x.push(true); } else { $(source).parents(".loginpanel").css({ "background-color": "#ecc8c8" }); arguments.isvalid = false; } } function loading(){ var confirmx = true; (var = 0; < x.length; i++) { if (x[i] != true) { confirmx = false; } } if (confirmx){ $(".loginpanel").on("click", "input[id*='login']", function() { loadingpage2("", "logging in..."); }); } } loading(); // run it! the thing need check code runs after validation functions. put code in end of script.
Comments
Post a Comment