• Resolved matn1mike

    (@matn1mike)


    I have a form I created in WPforms but it only has 1 submit button. I’d like to create a Button outside the form to clear all fields but the following does not work ouside the form on the Appearance edit page html shortcode <input type=”reset”>. Can you suggest a way either through a code snippet or shortcode how to access these fields and clear them if I create a button widget after the form but on the page. Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Amjad Ali

    (@amjadali688)

    Hi @matn1mike ,

    Thanks for reaching out!

    WPForms doesn’t have a built-in reset button, but you can achieve this with some custom JavaScript:

    document.addEventListener('DOMContentLoaded', function() {
    // Change the form ID to match your WPForms form ID
    var form = document.getElementById('wpforms-form-2927');
    if (form) {

    var clearButton = document.createElement('button');
    clearButton.type = 'button';
    clearButton.innerText = 'Clear';
    clearButton.class = 'custom-btn';
    clearButton.style.marginTop = '10px';

    clearButton.classList.add('custom-clear-button');


    form.appendChild(clearButton);


    clearButton.addEventListener('click', function() {

    var fields = form.querySelectorAll('input, textarea, select');
    fields.forEach(function(field) {
    if (field.type === 'checkbox' || field.type === 'radio') {
    field.checked = false;
    } else {
    field.value = '';
    }
    });
    });
    }
    });

    Since customizations like this are outside our scope of support, this is provided as a courtesy.

    If this solution isn’t quite what you’re looking for or doesn’t work as expected, we highly recommend posting your customization job here.

    Hope that helps!

    Plugin Support Amjad Ali

    (@amjadali688)

    Hi @matn1mike ,

    We haven’t heard back from you in a few days, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

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

The topic ‘My Reset HTML Code does not clear Wpform fileds’ is closed to new replies.