Skip to content

Commit

Permalink
Fix issue where expiration date marked as required inappropriately
Browse files Browse the repository at this point in the history
This field should only be required if General Admissions are enabled and a custom expiration date is set.
  • Loading branch information
joedolson committed Oct 30, 2024
1 parent ab39252 commit 7f462c5
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/js/jquery.showfields.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ jQuery(document).ready(function ($) {
const selector = $( 'select[name=mt_valid]');
if ( selector.val() === 'expire' ) {
$( '.expire_date' ).show();
$( '.expire_date input' ).attr( 'required', 'required' );
}
selector.on( 'change', function() {
if ( $( this ).val() === 'expire' ) {
$( '.expire_date' ).show();
$( '.expire_date input' ).attr( 'required', 'required' );
} else {
$( '.expire_date' ).hide();
$( '.expire_date' ).hide()
$( '.expire_date input' ).removeAttr( 'required' );
}
});
const regExpire = $( '#reg_expires' );
Expand All @@ -34,12 +37,12 @@ jQuery(document).ready(function ($) {
responseRegion.text( response );
});
if (initial_status !== true) {
$('.mt-ticket-form').hide();
$( '.mt-ticket-form' ).hide();
$( '.mt-ticket-form input' ).attr( 'disabled', 'disabled' );
$('.mt-ticket-data input').removeAttr('required').removeAttr('aria-required');
$( '.mt-ticket-data input' ).removeAttr('required').removeAttr('aria-required');
} else {
let general_status = $('input[name=mt_general]:checked').val();
if (general_status !== 'general') {
let general_status = $( 'input[name=mt_general]:checked' ).val();
if ( general_status !== 'general' ) {
$('.mt-ticket-dates input').attr('required', 'required').attr('aria-required', 'true');
$('.mt-available-tickets input').attr('required', 'required').attr('aria-required', 'true');
$('.mt-ticket-validity').hide();
Expand All @@ -60,7 +63,6 @@ jQuery(document).ready(function ($) {
}
if (checked_status == true) {
$( '.mt-ticket-form input' ).removeAttr( 'disabled' );
$('.mt-ticket-data input').attr('required', 'required').attr('aria-required', 'true');
$('.mt-ticket-form').show(300);
} else {
$( '.mt-ticket-form input' ).attr( 'disabled', 'disabled' );
Expand All @@ -80,6 +82,7 @@ jQuery(document).ready(function ($) {
$('.mt-ticket-dates input').attr('required', 'required').attr('aria-required', 'true');
$('.mt-available-tickets input').attr('required', 'required').attr('aria-required', 'true');
$('.mt-ticket-validity').hide();
$( '.expire_date input' ).removeAttr( 'required' );
}
});
});

0 comments on commit 7f462c5

Please sign in to comment.