I am working on a web form using JS Header for field validation. I have been tasked to add some optional fields on the form. I created two fields to accomplish these and one is a checkbox field and the other one is a text field. My problem is what should I add on the code below so that if a user enters text on the text field the system either places a checkmark automatically on the checkbox field or prompts the user to place a check mark on the checkbox field. This should work both ways also so that if a user places a check mark on the checkbox field then they get a prompt to enter text on the text field.Any help with this will be highly appreciated.
Heres my current JS Header:
function ValidateFields()
{
/* Check if mandatory fields contains values */
f = document.forms[0];
if (f.username_dt.value == “” ||
f.dept.value == “” ||
f.category.value == “”
)
{
alert(“You must complete all entries marked mandatory: \n\n Then submit this form!”);
f.sub.focus();
}
else
{
f.submitbutton.disabled=true;
f.submit();
}
}
function CannotSave()
{
alert(“You do not have priviledges to modify this information!”);
}