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

134
Vistas
Can I set j query validation to invalid without an input field?

I want to know if/how I can set custom validation. I’m working on a section to add items in a form, the user is asked if they would like to add an item, if they select yes, a section is made visible with all the input fields (description, value..) but the “add item”/“cancel” are <a> tags in a div and I haven't found a way to validate these like the rest of the inputs, instead I'm trying to see if the add/cancel div is visible (as this means the user didn't save the item details- when they select an option then the div is no longer visible). I’m looking for something along the lines of

$('form').validate(
    if ($(#add-or-cancel-div).is(':visible'){
        //validation = false
    }
)

I tried

$.validator.addMethod('itemRequiresAddOrCancel', function (element) {
    if (element.is(':visible')) {
        return false;
    } else { 
        return true;
    }}, "please pick an option");

$('form').validate(
    $(#add-or-cancel-div).rules('add', 'itemRequiresAddOrCancel');
    }
)

Is this the best way to approach this or can it be done another way?

about 4 years ago · Juan Pablo Isaza
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