Multifield validation

Avatar

Avatar

v1101

Avatar

v1101

v1101

01-02-2021

Hello - I have a composite multifield which has the below fields. Based on the checkbox selection (If I uncheck), I am making the Product URL field as mandatory which has all the required elements ( aria-required="true"). If I don't select the URL/Type the URL, it is still letting me to submit the dialog which shouldn't happen. But if I enter a space, it is showing as mandatory. is there any way to handle this ?

 

 

v1101_0-1612229860020.png

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Anudeep_Garnepudi

MVP

Avatar

Anudeep_Garnepudi

MVP

Anudeep_Garnepudi
MVP

01-02-2021

@v1101 

Try the below snippet.

 

$(document).on("change", ".aciveproduct", function(e) {
    if($(this).prop("checked")) {
        $(this).closest(".coral3-Multifield-item").find("foundation-autocomplete").removeAttr("required");
    } else {
        $(this).closest(".coral3-Multifield-item").find("foundation-autocomplete").attr("required", "required");
    }
});

 

Hope this works. 

Answers (1)

Answers (1)

Avatar

Avatar

Veena_Vikram

MVP

Avatar

Veena_Vikram

MVP

Veena_Vikram
MVP

01-02-2021

Do you have a jquery you have written to handle the same ? I doubt there is something wrong with the logic you have written to make the fields mandatory.