• Resolved altimac

    (@altimac)


    Hi, having an issue with a select dropdown field that has a list of values in it:

    1.0 to 2.0
    2.5
    3.0
    3.5
    4.0
    4.5
    5.0
    5.5+

    I have made it required, and used a placeholder –Select– so that the visitor is prompted to choose one of the options. But when the form loads, the field is ALREADY showing an error message that the field is required. Is there a way to prevent this from happening until the form is submitted, or at least until that field gets focus and then loses focus without an option being selected? My client keeps telling me there is something wrong with the form, because that field is showing the required message before anyone even has a chance to fill it out.

    The page I need help with: [log in to see the link]

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Williams – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @altimac

    Hope this message finds you well.

    After testing the Selec field on my test site, I could not reproduce the issue

    The –Select– is set as a Placeholder:

    https://prnt.sc/pQryR9zYkYDV

    No selection no error:

    https://prnt.sc/FnVDllM_Hrsy

    Still, we would like to take a look at the form, could you export your form using the guide on this link: https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#import-export? Once exported, kindly use a Cloud service like Google Drive, pastebin.com, or similar to share it. If you have sensitive data, please duplicate the form, remove it, and export the form.

    Best regards,
    Laura

    Thread Starter altimac

    (@altimac)

    Hi, Laura and thank you for checking this. I have exported the form and placed it here:

    https://media.altimac.com/sport-tour.json

    No matter what I do I see the “reqiured” message, as soon as the form is loaded. Screen shot here:

    https://media.altimac.com/sport-tour.png

    Thread Starter altimac

    (@altimac)

    Plugin Support Williams – WPMU DEV Support

    (@wpmudevsupport3)

    Hi @altimac

    Thanks for the form, it was really helpful.

    After a couple of tests, I was able to reproduce the same on my site, the issue seems to be related to the Stripe field, after removing it the error went away.

    In such a case, I escalated and reported this to our Second Line Support, and they will check closer and provide further information, since they work on very complex issues, getting a reply from them could take longer than usual. Your patience on this is greatly appreciated.

    We will back to this topic once we get an update from them, in the meantime I would suggest disabling the required option from the Select field.

    Best regards,
    Laura

    Thread Starter altimac

    (@altimac)

    Thank you and I appreciate your looking into it.

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @altimac

    Could you please try this script:

    <?php
    
    add_action( 'wp_footer', 'wpmudev_select_field_change_fix', 9999 );
    function wpmudev_select_field_change_fix() {
    	global $post;
    	if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) {
    		return;
    	}
    	?>
    	<script type="text/javascript">
    	jQuery(document).ready(function($){		
    		$(document).on('after.load.forminator', function(e, form_id) {
    			if ( form_id === '46772' ) { // Please change 46772 to your form ID.
    				setTimeout(function(){
    					var holder      = $('#select-2 select');
    					var holderField = holder.closest( '.forminator-field' );
    					var holderError = '';
    					
    					var errorId = holder.attr('id') + '-error';
    					var ariaDescribedby = holder.attr('aria-describedby');
    					
    					holderError = holderField.find( '.forminator-error-message' );
    					
    					// Remove or Update describedby attribute for screen readers
    					if (ariaDescribedby) {
    						var ids = ariaDescribedby.split(' ');
    						ids = ids.filter(function (id) {
    							return id !== errorId;
    						});
    						var updatedAriaDescribedby = ids.join(' ');
    						holder.attr('aria-describedby', updatedAriaDescribedby);
    					} else {
    						holder.removeAttr('aria-describedby');
    					}
    					
    					// Remove invalid attribute for screen readers
    					holder.removeAttr( 'aria-invalid' );
    					
    					// Remove error message
    					holderError.remove();
    					
    					// Remove error class
    					holderField.removeClass( 'forminator-has_error' );
    				},500);
    			}
    		});
    	});
    	</script>
    	<?php
    }

    Please, update the 46772 by using your form ID + the $(‘#select-2 select’) to your select field number, add it as a mu-plugin https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Best Regards
    Patrick Freitas

    Thread Starter altimac

    (@altimac)

    Thank you, Patrick. That did the trick! I added it using CodeSnippets, assuming that’s OK and that creating a plugin is just another way to get the code to load on the site?

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @altimac

    Yes, the mu-plugins are a safer way to add custom code without the need to create a child theme or using the snippet plugins.

    Note, that is also a bug in the plugin and we reported to our developers, we can’t give an estimate time to release the fixed version but you can keep the mu-plugin as long as you need.

    Best Regards
    Patrick Freitas

    Thread Starter altimac

    (@altimac)

    OK, sounds good. Thanks again for acknowledging the issue and providing a quick fix.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Issues with select field showing as required on form load’ is closed to new replies.