Landing Page Custom Validation


#1

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.


#2

You want to post the scripts, firstly?


#3

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.


#4

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?))


#5

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


#6

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