forms 2.0 validation on a select all option check box

Michelle_Tizian
Level 10

forms 2.0 validation on a select all option check box

Does anyone know where I can find the javascript or jquery to add to my forms2.0 for the check box options that I have.  So if my check box options are the following:

Americas
Asia Pacific
Europe
All Regions

If they select "All Regions" I want the other check boxes deselected.  Also do I add this on the CSS or on the landing page?
Tags (1)
2 REPLIES 2
Anonymous
Not applicable

Re: forms 2.0 validation on a select all option check box

Jquery will do the trick. See this link
http://stackoverflow.com/questions/8423217/jquery-checkbox-checked-state-changed-event

This should go in your landing page, not the CSS.

 
Alok_Ramsisaria
Level 10

Re: forms 2.0 validation on a select all option check box

Here the whole code that you'll need:

Let's consider that your All Regions checkbox field has id- 'AllRegions'

Just put this whole code in your landing page, when you drag an HTML element of your drafted LP:

MktoForms2.whenReady(function (form){

$('#AllRegions').click(function(event){

if($(this).is(":checked")){

$(".mktoFormRow input[type='checkbox']").each(function(index, el) {                $(el).prop({"checked": false});                $(el).attr('disabled', true);                              });            $(this).prop({"checked": true});

}else{

$(".mktoFormRow input[type='checkbox']").each(function(index, el) {                $(el).attr('disabled', false);            });

}

});

Hope this solves your problem