checkbox in dialog

Avatar

Avatar

Shaheena_Sheikh

Avatar

Shaheena_Sheikh

Shaheena_Sheikh

08-03-2021

I have a checkbox in my dialog box. I have added the property "value" and value as "true" (string). When i open my dialog box, and if check/uncheck the checkbox, i always see the console log "check true". How can i get the correct detail if the checkbox is checked/unchecked?

I am using granite:data node and the below js code:

$(window).adaptTo("foundation-registry").register("foundation.validation.validator", {
selector: "[data-checkbox]",
validate: function(checkbox) {
var check= checkbox.value;
console.log("checks " + check); //always showing true

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Anudeep_Garnepudi

MVP

Avatar

Anudeep_Garnepudi

MVP

Anudeep_Garnepudi
MVP

08-03-2021

@Shaheena_Sheikh 

Use var check= checkbox.checked; instead of var check = checkbox.value;

Answers (2)

Answers (2)

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883

Avatar

Arun_Patidar

MVP

Total Posts

3.1K

Likes

1.2K

Correct Reply

883
Arun_Patidar
MVP

08-03-2021

Either use native javascript or jquery, Please check all the supported method for Coral3 checkbox at https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/coral-ui/c...

Avatar

Avatar

Shaheena_Sheikh

Avatar

Shaheena_Sheikh

Shaheena_Sheikh

08-03-2021

I just realised the line should be 

var check = $(".cq-dialog").find("#checkbox")[0].checked; instead of

var check = $(".cq-dialog").find("#checkbox")[0].value;