I have a form that has several fields all within the class Contact
that have a common header.
I need that header to turn red whenever the user hits submit with any contact field unfilled. These fields (first_name, last_name, company, Marketing_Phone, email) already have the class error
added when submitted empty.
These fields are all in the class wrap_contact
with the label Contact Information *
. This label does not receive the class error
on submit. This is what I need to add. I gave the label an id of label2
. So my if then is if first_name, last_name, company, Marketing_phone, or email is null on submit then label2
has the error
class added.
I attempted adding the following code, but it did not work.
$( "#pardot-form" ).submit(function( event ) {
var someElements = document.querySelector("p.error,input[name=263882_11763pi_263882_11763]}");
if (someElements !== "") {
document.getElementById('p.label2').addClass = 'error';
}
};
This form is visible online at http://link.rubiconglobal.com/l/263882/2017-03-24/7ssj.