Landing Page Custom Validation

  • 5 September 2018
  • 6 replies
  • 32 views

Hi All,

I wanted to add custom validation to my landing page. I tried to used Javascript codes but it’s not working.

Here’s the validation need.

  1. User need to at least select 1 checkbox before they submit
  2. User need to input the text box field if they select Others(checkbox)

Thank you.


6 replies

You want to post the scripts, firstly?

I tried the validation in number 2.

Here is my code.

$(document).ready(function() {

$('input[name="elqOther"]').change(function() {

    if ($('input[name="elqOther2"]').attr('required')) {
        $('input[name="elqOther2"]').removeAttr('required');
    } 

    else {
        $('input[name="elqOther2"]').attr('required','required');
    }

});

});

I just want to put required in Textbox(Other Text) if the Checkbox (Other Checkbox) is checked.

For Validation point 1 I need to select at least 1 checkbox before submission. ( The checkbox are different ID’s so I can’t just tick check the required rule inside the form)

Thank you.

Hmmm you have a link to the page?

((I am assuming that you’ve check the source to see if required is being added correctly?))

Here’s a related post by the Unbounce team: Adding custom validation to form fields

Hi! @mccamon can you look to my question in that thread? I have an error in the console and can’t find what is missing

Userlevel 3
Badge +1

For anyone who comes across this post, we recently added a similar option while you’re editing your forms within the builder directly. Check it out here!

Reply