We are using Formassembly to create our forms and currently we have a form which is both used by internal and external users. There is a checkbox in the form which distinguishes between internal & external users. I need the code to check if the "Internal" checkbox is ticked or not, if the "Internal" checkbox is ticked the email field needs to be optional otherwise the email field needs to required. I assume it can be achieved by Javascript or please advise if there is any other way. I have no idea in coding but tried looking up online and tried to code but it doesn't work. Please help.
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
{
//#tfa_78 is the checkbox
if($("#tfa_78").is(":checked")) {
//#tfa_1 is the email field
this.getField("#tfa_1").required = false;
}
else
{
this.getField("#tfa_1").required = true;
}
});
});
</script>