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

100
Views
Multiple error messages, based on another field

I tried to make the error message dynamically:

window.Parsley.addValidator('validatorName', {
    requirementType: 'string',
    validateString: function (value) {
    return validateField(value);
    },
    messages: {
        en: 'Invalid ' + someValue
    }
});

But it doesn't change, it set someValue to the first value it was set in the page.

How can I change the message based on this value dynamically?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

I would put the logic to get the dynamic value into a function and then call that function in your validator.

function getValue() {
    let returnValue = "";
    // logic to get the value of someValue
    returnValue = someValue
    return returnValue;
}
window.Parsley.addValidator('validatorName', {
    requirementType: 'string',
    validateString: function (value) {
    return validateField(value);
    },
    messages: {
        en: 'Invalid ' + getValue()
    }
});
about 4 years ago · Santiago Trujillo 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!