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

114
Vistas
Making a jQuery Custom Validator Optional

I added a custom validation method to jQuery Validation such as:

$.validator.addMethod('myregex', function (value) {
    return /\d/.test(value);
}, 'Please enter a valid input.');

Note that I know there is a build in number check. That is just an example, I actually want to use more custom regex validators.

The problem is that now the field form is always required. Even if I set the value required to false in the code such as:

   $("form[name='my-form']").validate({
        // Specify validation rules
        rules: {
            form-field: {
                required: false,
                myregex: true
            },

I want my regex to check if the data entered on a field is valid, but not force the field to be completed as its optional.

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