Really trying to finish this site for launch tomorrow and need to block bad date formats on the registration DOB field.
My code so far is working in that it changes the field green and shows the validation span after the field but on submit it is not stopping them from progressing to make payment
any ideas where im going wrong please
thank you
This is in my functions.php and I;m using moment.js to validate the value to USA format MM/DD/YYYY which works ok
// add script to registration form
add_action( 'AHEE__attendee_information__reg_step_start', 'eea_dob_validation' );
function eea_dob_validation() {
?>
<script>
jQuery(document).ready(function($) {
// handle the submit button
$('#spco-go-to-step-finalize_registration-submit').click(function() {
var studentdob = $('input.ee-reg-qstn-12').val();
var studentdobvalidate = moment(studentdob, 'MM/DD/YYYY', true);//test is USA date... true at end means strict match
if(studentdobvalidate.isValid()) {
//all ok on DOB
} else {
alert('Please use the date picker for date of birth ensuring a US format is used (MM/DD/YYYY).');
return false;
}
Ha ha why is it you can spent 2-3 hours trying to get something working and the minute you succumb and post in to the forum you then get some kind of inspiration and see the answer 🙂
My click action was on #spco-go-to-step-finalize_registration-submit
when my form is actually using
$(‘#spco-go-to-step-payment_options-submit
So Ive changed to button ID and its now stopping the form from progressing as I wanted…
thanks all sorted
Viewing 1 reply thread
The support post ‘Date of birth validation not stopping form progressing’ is closed to new replies.
Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.
Support forum for Event Espresso 3 and Event Espresso 4.