Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Check box checked automatically, if the imagefiled or textfield filled out

Avatar

Level 3

if.jpghow can I make the checkbox being checked  IF there particular imagefield or textfield filled out ?

I need the code please

0 Replies

Avatar

Community Advisor

where you need to do this, In dialog or in a page?

Anyways It can be done by using jQuery event listenser. where you can attach blur event on textfield and based on input checkbox can be checked/unchecked using jquery/javascript.

Avatar

Level 3

when you fill out (imagefield1 ) with any photo , then (chekbox1) return to ((cheked))

and when you fill out (textfield1) with any text, then (checkbox 1 ) return to (checked)) and such ....

the checkboxes are on the top of the form (( like a result )))

the event on (exit*)

I need the whole code for on one (Q) then I gona copy busy rename the rest fields ..

Untitled.jpg

Avatar

Community Advisor

You can try below for textfield and same can be implemented for image

Edit fiddle - JSFiddle

<input type="checkbox" id="box" name="box" value="">

<input type="text" id="comment" name="comment" value="" />

$(document).ready(function() {

    $("#comment").on("keyup blur", function() {

        $("#box").prop("checked", this.value !== "");

    });

});

Avatar

Level 3

<input type="checkbox" id="box" name="box" value="" checked>

<input type="text" id="comment" name="comment" value="" /> 

where mus I put the name of (chekbox ) and TextField ??

Avatar

Community Advisor

where are you planing to create those forms? in AEM or outside AEM.Or is it related to AEM forms?