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

145
Vistas
tratando de crear una función de validación para el código js personalizado

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

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