tengo esta funcion
function validateAndSend() { if (frmVendor.CompanyName.value == '' && frmVendor.LastName.value == '') { alert('You have to enter a Company Name or an Individual First and Last Name.'); return false; } else if(frmVendor.CompanyName.value != '' && frmVendor.LastName.value != ''){ alert('The Vendor has to be either a Company or an Individual, but not both.'); return false; } else if(frmVendor.CompanyName.value != '' && frmVendor.FirstName.value != ''){ alert('The Vendor has to be either a Company or an Individual, but not both.'); return false; } else { frmVendor.validate(formObj()); frmVendor.submit(); } }Lo intenté así y parece que me faltan algunas partes clave aquí sobre el código que estoy escribiendo, pero ¿cómo puedo hacer que funcione?
$.validator.addMethod( "comparedata", function( value, element ) { if(element.CompanyName.value == '' && element.LastName.value == '') { txt = 'You have to enter a Company Name or an Individual First and Last Name.' } else if(frmVendor.CompanyName.value != '' && frmVendor.LastName.value != ''){ txt = 'The Vendor has to be either a Company or an Individual, but not both.'; return false; } else if(frmVendor.CompanyName.value != '' && frmVendor.FirstName.value != ''){ txt = 'The Vendor has to be either a Company or an Individual, but not both.'; return false; } return txt }); pero no funciona correctamente y estoy tratando de agregarlos como data-attributes