Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

139
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda