Hello all,
Looks like there is a conflict between the PHP script and JS. JS is expecting an array of errors from the PHP script, but the PHP is set up to only return one error at a time. Logically, it should only return one error at a time to the user as it will not overload the page content.
the pages this form appears on
After the user fills out the second form to confirm their e-mail along with a few other surface details, it should return one error at a time to be populated into #errormessage ul until the submission is a valid one. Currently, if there is an error, it displays the error message text, only without any actual errors as a list item.
lpemailbox.js (lines 47-57)
var fragment = document.createDocumentFragment();
$.each(data['errors'], function (i, e) {
var item = document.createElement('li');
if (typeof item.textContent === "string") {
item.textContent = e;
} else {
item.innerText = e;
}
fragment.appendChild(item);
});
$("#errormessage ul").empty().append(fragment.childNodes);
confirmform.php (lines 23-50)
if ($origEmail != $confirmEmail || empty($confirmEmail)) {
$response['errors'][] = 'E-mail addresses don\\'t match.';
$status = 0;
}
if (empty($name) || preg_match('/[^A-Za-z ]/', $name)) {
$response['errors'][] = 'No name entered (name can only have letters).';
$status = 0;
}
if (!ctype_digit($age)) {
$response['errors'][] = 'Age must be numeric.';
$status = 0;
}
if ($country == "Select Location") {
$response['errors'][] = 'No location selected.';
$status = 0;
}
if ($mathAnswer != $rightAnswer) {
$response['errors'][] = 'Math answer incorrect.';
$status = 0;
}
if (!empty($catcher)){
$response['errors'][] = 'Bot submission.';
$status = 0;
}
if ($submissionTime < 9000){
$response['errors'][] = 'Form submitted too quickly.';
$status = 0;
}
Any ideas or suggestions?
Thanks,
Tyler
edit: Kudos to fretburner for helping to construct the original script.