Hi Luc,
I usually send the form via Ajax, so it’s seamless.
I’m using the JQuery validation plugin but you could call the SubmitPasswordReset() function directly on the form submit button…
Here’s the JavaScript for the validation trigger and Ajax call:
//### RESET PASSWORD ###
$("#forgot-password-form").validate({
submitHandler: function(form) {
//### Disable the Submit button ###
$("#forgot-password-form button").fadeTo("slow", 0.20).attr("disabled","disabled");
SubmitPasswordReset();
return false;
}
});
//### RESET PASSWORD FORM SUBMISSION ###
function SubmitPasswordReset() {
//### Send form via AJAX ###
$.ajax({
type: "POST",
data: $("#forgot-password-form").serialize() + "&action;=" + $("#forgot-password-form").attr("action"),
dataType: "html",
success: function (html) {
//### Successfully received an html page from the server ###
if ( html.search(/error/i) >= 0 ) {
if (html.search(/not found/i) >= 0) {
$("#pwd-reset-email").addClass('error');
$("#pwd-reset-email").after('<label class="error" for="login-username" generated="true">Email address doesn\'t exist
Re-check or register an account</label>');
} else if (html.search(/already logged in/i) >= 0) {
$("#forgot-password-form button").after('<label class="error" for="login-username" generated="true">User already logged in!</label>');
} else if (html.search(/account has not been activated yet/i) >= 0) {
$("#forgot-password-form button").after('<label class="error" for="login-username" generated="true">Account has not been activated yet
Check your email and activate</label>');
} else {
}
$("#forgot-password-form button").fadeTo("slow", 1).removeAttr("disabled");
} else {
//### Successfully sent reset request ###
//"Instructions for resetting your password have just been emailed to you."
$("#forgot-password-form").hide();
$("#password_reminder .form-success").slideDown("slow");
//### Show/hide user nav links ###
ClearForm("#forgot-password-form");
//### Close PrettyPhoto Popup Window ###
var currentURL = new Array();
currentURL = top.location.href.split('#');
top.location.href = currentURL[0] + "#close-pp-delay";
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
//### Error occurred, could be server, CMS or 404 ###
//alert(textStatus + errorThrown);
$("#forgot-password-form button").fadeTo("slow", 1).removeAttr("disabled")
},
complete: function (XMLHttpRequest, textStatus) {
//alert(textStatus);
}
});
} //### End of SubmitLogin function ###
Note the checks in there for the various errors from EE.
I can’t recall what I did for the AVA site or what the above does without JavaScript - think the EE panel will appear, which I’ve customised to give it some branding.
Hope this is helpful.
Peter