Friday, 27 September 2013

Run javascript function after another is successful

Run javascript function after another is successful

I call a validate form function in the following way:
$(document).ready(function () {
$('#MainContent_btnRegisterClient').click(function (e) {
return validateForm('.registerClient',
'#MainContent_lblRegStatus', '#MainContent_txtClientEmail', e);
});
});
Which calls my validateForm and then validateEmail:
//textbox validation
function validateForm(className, message, email, e) {
var isValid = true;
//empty validation
$(className).each(function () {
if ($.trim($(this).val()) == '') {
isValid = false;
$(message).text(errAllfields);
$(message).fadeIn();
$(this).css({
"border": "1px solid #036447",
"background": "#B5E0D2"
});
}
else {
$(this).css({
"border": "",
"background": ""
});
}
//prevent form submission
if (isValid == false)
e.preventDefault();
});
//if all fields complete
if (isValid == true) {
//if email field entered then validate
if (email != null) {
if (!validateEmail(email, message)) {
return false;
}
}
}
}
However I then want to add another function (password and password confirm
compare function) to be run after these ones are successful. What is the
best way to accomplish this? Can I call it straight from my aspx page?
Thanks

No comments:

Post a Comment