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

205
Visualizações
How to stop update on keyup if the error message is the same with Jquery validate

Whenever I type in Jquery validated field on max and min number of letters, I get a refresh of messages even though the error is the same. How do I prevent that so it is less irritating for the users?

The code is

    validations = {
        'rules':{
            'code': {
                'minlength': 9,
                'maxlength': 9
            },

        },
        'messages': {
            'code': {
                'minlength': 'Must be 9 digits',
                'maxlength': 'Must be 9 digits'
            },
        }
    }

I have tried to use showerror(), and check whether the error list is the same, but I can't prevent the previous error messages from disappearing.

        showErrors: function(errorMap, errorList) {
            if(typeof prev_error_map != "undefined"){
                if (!_.isEqual(prev_error_map, errorMap)) {
                    this.defaultShowErrors();
                    prev_error_map = errorMap;
                }
            }else{
                this.defaultShowErrors();
                prev_error_map = errorMap;
            }
        }
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

So I figured out my mistake. Instead of doing

'minlength': x,
'maxlength': y

I should have done

'rangelength': [x,y]

This way, the length is only checked once and potential updates are avoided.

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