我的网站上有“重新发送激活”表单。基本上访问者输入了他们的电子邮件地址,我怨恨原始的激活电子邮件。
问题是,如果他们输入电子邮件地址并点击提交,然后输入一个不同的电子邮件地址(即他们错误输入了原始电子邮件),那么它仍然只是使用他们的第一个输入。
以下是代码:
// *****************************************************
// CHECK FORM WHEN TRYING TO RESEND ACTIVATION
// *****************************************************
$('#form-resend-activation').on('submit', function(e){
$('#formTitleText').text(ajax_login_object.loadingmessage);
var error = false;
// Declare the function variables - parent form, form URL and the regex for checking the email
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
// Start validation by selecting all inputs with the class "required"
if($('#username').val() == ''){
$('#username').addClass('error');
$('#formTitleText').text("Please enter an email address");
error = true;
}
// Run the email validation using the regex for those input items also having class "email"
if(!emailReg.test($('#username').val())){
$('#username').addClass('error');
$('#formTitleText').text("Enter a valid email address");
error = true;
}
// All validation complete - check whether any errors exist - if not submit form
if (!error) {
$.ajax({
type:"post",
dataType: 'json',
url:ajax_login_object.ThemeFolder+ajax_login_object.auxFunctionsFolder+"/check_login_details.php",
data: {
'username': $('#username').val(),
'originatingPage': ajax_login_object.redirecturl,
'resend_activation': true,
'security': $('#security').val() },
success:function(data){
if(data.done_successfully == true) {
// THIS HAS HAPPENED SUCCESSFULLY
$('#formTitleText').html("<div class='login_message_box'><img src='"+ajax_login_object.ThemeFolder+"/images/loginbox/tick.png' class='JTloginFormImage'> "+data.message+"</div>");
} else {
// THIS HAS NOT HAPPENED BECAUSE THEY AREN'T IN THE DATABASE
$('#formTitleText').html("<div class='login_message_box'><img src='"+ajax_login_object.ThemeFolder+"/images/loginbox/cross.png' class='JTloginFormImage'> "+data.message+"</div>");
}
}
});
}
e.preventDefault();
});
// *****************************************************
// END OF RESEND ACTIVATION FORM
// *****************************************************
如果有人对此有任何想法,那么我会全力以赴。我是jquery的新手,所以才真正找到了解决方法。非常感谢
约翰; - )