• Resolved pawsitforward

    (@pawsitforward)


    My forms used to submit only when you clicked on the submit button. Now when you click enter on the keyboard it will send the form, regardless if its been filled out or not.
    How can I fix this?

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

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

    (@wpmudev-support8)

    Hi @pawsitforward

    I hope you’re well today!

    This should only be happening if either there are no “required” fields on form or they are there but were already filled in. Also, if there’s inline validation enabled, the data in fields must properly validate.

    Is this working that way for you or it “always” submits the form, no matter what (if required fields are filled-in or not, if values validate or not)?

    I also asked our Forminator Team if there’s a simple way to disable that “on enter” submit and I’m waiting for their feedback but meanwhile, please let me know about above.

    Best regards,
    Adam

    Plugin Support Saurabh – WPMU DEV Support

    (@wpmudev-support7)

    Hello @pawsitforward,

    Our team went ahead and made a quick snippet that should disable the on click Enter Submission on the form. Here is the code:

    add_action( 'wp_footer', function(){
    	?>
    	<script>
    		(function($){
    			$(function(){
    				$(window).on('load', function(){
    					let list_form_ids = [],
    						_forms,
    						_entering = 0;
    					if( list_form_ids.length ){
    						_forms = $('#forminator-module-'+ list_form_ids.join(',#forminator-module-'));
    					}else{
    						_forms = $('.forminator-custom-form');
    					}
    
    					if( _forms.length ){
    						_forms.find('.forminator-button-submit').on('click', function(e){
    							_entering = 0;
    							e.preventDefault();
    							let _form = $(this).closest('form');
    							setTimeout(function(){
    								if( ! _entering ){
    									_form.trigger('submit');
    								}
    							}, 500);
    						});
    						_forms.find('.forminator-input, .forminator-textarea').off('keydown keyup');
    						_forms.on('keyup', 'input', function(e){
    							let _keycode = e.which || e.keyCode;
    							if( 13 === _keycode ){
    								_entering = 1;
    							}
    							return;
    						});
    					}
    				});
    				});
    		})(window.jQuery);
    	</script>	
    	<?php
    }, 21 );

    Now you can also install it as a mu-plugin if you like. Here is how you can install it like a mu-plugin:
    https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins

    Let me know if that works for you.

    Thank you,
    Prathamesh Palve

    Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @pawsitforward ,

    We haven’t heard from you for a while now, so it looks like the code above helped.

    Please feel free to re-open this ticket if needed.

    kind regards,
    Kasia

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Form Submitting by clicking Enter’ is closed to new replies.