I would like to copy the first field value into the second field when the checkbox is checked and before submitting the form. I have used the below code in JS of the user form.
function copyTextValue() {
if(document.querySelector("input[name='wpcf-agree']").checked){
var email = document.querySelector("input[name='user_email']").value;
document.querySelector("input[name='nickname']").value; = email;
}
}
we have tested the code it was working fine outside WordPress, but it is not working when I used it here. What is wrong with it??
Onclick is not a valid attribute for our Toolset Forms shortcodes. In order to implement your solution the best way is to trigger the jQuery trigger. See details below.