I have a form. I need this script to not validate the textarea if the second element exists on the page. I can not remove the textarea validation from the script, since it is used to validate an input on another form.
Is there any way to ignore this if statement if my second element exist in the page?
This is my js:
if ( $('textarea').val()=="") {
showOverlay();
errors[errors.length] = ' enter your feedback';
}
if ( $("#edit-vertical-title").val()=="" ) {
showOverlay();
errors[errors.length] = ' enter your menu item';
} else {
}
Just add a check to see if the element exists within the first if statement using jQuery length, like so: