I have a php form that gets validated through javascript. I would like to add another field to the form where the user has to confirm their email. How can I do this in the javascript validation file please?
Here is my current validation for the initial email form:
this.setHandler('email',
function (value) {
regex=/^[a-zA-Z0-9._-]+@([a-zA-Z0-9.-]+\.)+[a-zA-Z0-9.-]{2,4}$/;
return regex.test(value);
}
);
Adapt something like this…
Assuming your confirm email‘s
name(or whatever the first argument tosetHandler()) isemail-confirm, and the original email input’snameisemail(and assuming it is the first element of such).Basically, I’m comparing the current value of the
email-confirmto the original value, and if they are equal, the function returnstrue.