0

Now that I thin k of it, is it possible to add attributes (functions or required classes) to the submit button in a freeform:edit form? ...................

I'm using Freeform Pro's both form and edit forms and need a required checkbox field on the edit form. Unfortunately I am not having any success.

The architecture is as follows:

  1. user fills in fields and submits form (button is labelled continue)
  2. user is taken to a review form (freeform:edit) where they can update their information. On this page I have added an additional required checkbox field that needs to be checked prior to submit.

The problem with freeform is that this field already has a value (n). What I need to do is remove this value on load of the edit form page and make this field required.

It seems as though the only attr available to add a function is onclick. Unfortunately, nothing will be clicked. I need the chaeckbox to be required without anything being clicked.

The reason I set up the form this way is because I want the user to be able to edit their info before the confirmation email is sent. The confirm email is sent once the edit form is sent.

Is this possible? I'm assuming it is and that I'm missing something

Thanks

Peter T

1

You could use the onsubmit parameter of the Form to check and see if the checkbox is still 'n' and alert the user before allowing the submit:

<script type="text/javascript">
    function checkboxTicked()
    {
        var checkbox = document.querySelector('#edit_form input[name="myCheckbox"]');

        if (checkbox.value == 'n')
        {
            //force alert to wait until the form submit has resolved.
            setTimeout(function(){
                alert('please check the checkbox before sumbmitting');
            },10);

            return false;
        }
        else
        {
            return true;
        }
    }
</script>

{exp:freeform:edit entry_id="1" form:id="edit_form" form:onsubmit="return checkboxTicked();"}
    //form stuff here
{/exp:freeform:edit}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.