Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

140
Vistas
trying to create a validation function for custom js code

i have this function

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();
}
}

i tried like this and it seems i am missing some key parts here about the code i am writing but how can i make it work,

$.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
});

but its not working properly and i am trying to add them as data-attributes

about 4 years ago · Santiago Gelvez
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda