Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!