Check box checked automatically, if the imagefiled or textfield filled out | Community
Skip to main content
Level 2
December 26, 2018
Question

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

  • December 26, 2018
  • 6 replies
  • 3554 views

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

I need the code please

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

6 replies

arunpatidar
Community Advisor
Community Advisor
December 26, 2018

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.

Arun Patidar
Level 2
December 27, 2018

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 ..

arunpatidar
Community Advisor
Community Advisor
December 27, 2018

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 !== "");

    });

});

Arun Patidar
Level 2
December 27, 2018

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

arunpatidar
Community Advisor
Community Advisor
December 27, 2018

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

Arun Patidar
smacdonald2008
Level 10
December 27, 2018

This is AEM Forms designer. You need to use JS Script for AEM Forms designer.

https://helpx.adobe.com/pdf/aem-forms/6-2/scripting-basics.pdf