• Resolved jacksn676

    (@jacksn676)


    Would like to add in ‘Reset / Clear’ form button.
    However, the form reset method is not working to reset/clear the form when the button clicked using the custom script.

    Is there any alternative way to reset the form when button clicked?

    Tested below methods but not working:
    # $(‘form’).trigger(‘reset’);
    # $(‘form’)[0].reset();

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nithin John

    (@nithi22)

    Hi,

    Thanks for reaching out to us.

    By default, there is no option for reset application form. But you can use the below code snippet.

    add_action('awsm_application_form_field_init', 'awsm_application_form_reset');
    
    if ( ! function_exists( 'awsm_application_form_reset' ) ) {
    	function awsm_application_form_reset() {
    		echo '<input type="button" id="awsm_reset_form" value="reset" />';
    	?>
    		<script>
    			jQuery(function($) {
    				var $form =  $('.awsm-application-form');
    				var form = $form[0];
    
    				$('#awsm_reset_form').click(function() {
    					$form[0].reset();
    				});
    			});
    		</script>
    	<?php
    	}
    }

    Resources: https://wp-content.co/add-custom-code-to-your-wordpress-websites/

    Regards
    Nithin John

    Thread Starter jacksn676

    (@jacksn676)

    Hi Nithin John,

    Thanks for prompt reply.

    Sorry for the confusion.
    Actually I would like to add in the reset button for the filter form not the application form.
    I have found an alternative way to achieve it using javascript.

    $('.resetcta').on('click', function(){
    select.find('option:not([value=""])').prop('selected', false);
    select.find('option[value=""]').prop('selected', true).trigger('change');
    });

    However, if there is any hooks to achieve it would open for advices.

    • This reply was modified 1 year, 5 months ago by jacksn676.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Reset / Clear form’ is closed to new replies.