&& operator is not working
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-30-2024 09:46 AM - edited 09-30-2024 10:09 AM
Hello,
May someone assist me in troubleshooting my code? I trying to prevent a user from submitting a form if a specific checkbox is not true (checked) as well as if there are no attachments on the form. However, the AND operator is not working as expected.
var checkbox = g_form.getValue('test');
var countRequired = 0;
if (window == null) {
// portal
if ( (this.document.getElementsByClassName('get-attachment').length == countRequired) &&
(checkbox == true) ) {
g_form.addErrorMessage('Please add the required attachments.');
return false;
} else {
// native view
var length = $j("li.attachment_list_items").find("span").length;
if ( (length == countRequired) && (checkbox == true) ) {
g_form.addErrorMessage('Please add the required attachments.');
return false;
}
}
}
With this code, the submission goes through with a javascript error.
Thanks