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

The 4th edition of the Campaign Community Lens newsletter is out now!

How to get mirror values from one field to another when checkbox is checked in webpage


Level 4

Hi All,

We are trying to get mirror value from one field to another when a checkbox is checked.

While trying we are getting issues as mentioned below.

1. when checkbox is checked and webpage is submitted, the 2nd field (the field in which the values came as mirror from 1st field) is showing validation/mandatory issue.

2. If we just select the 2nd field in webpage after checking the checkbox and the mirror values is taken in to 2nd field the validation/mandatory issue is not coming and able to submit the form.


Can someone please help resolve this issue ASAP?


Thanks & Regards,


@Manoj_Kumar_ @DavidKangni @Deb_Tripathy @Marcel_Szimonisz 

1 Reply


Level 4

1st field code:

<li><label class="desc" id="title1">First Name <span class="req" id="req_4">*</span></label>
<div><input name="fname" class="inputwidth" id="fname" type="text" placeholder="First Name" data-nl-bindto="xpath" data-nl-xpath="@firstName" data-nl-ismandatory="true" data-nl-label="First Name" /></div>

2nd field code:

<li><label class="desc" id="title1">First Name <span class="req" id="req_4">*</span></label>
<div class="inputwidth"><input name="fname2" class="fname2" id="fname2" type="text" placeholder="First Name" data-nl-bindto="xpath" data-nl-xpath="@firstName2" data-nl-ismandatory="true" data-nl-label="First Name" /></div>


Mirroring script:

$("#mirror").change(function() {

var checkbox = document.getElementById('mirror').checked ;
if(checkbox = true){

var Pfirstname = document.getElementById("fname").value;

var Afirstname = Pfirstname;

document.getElementById("fname2").value = Afirstname;
document.getElementById("fname2").value = '';


The ultimate experience is back.

Join us in Vegas to build skills, learn from the world's top brands, and be inspired.

Register Now