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

212
Views
Delete invalid values being validated by Parsely.js without the user having to delete them on their own while maintaining the validation message?

Hello much more knowledgeable developers of the world,

My question as asked in the title is that if it is possible to delete the invalid values entered that are being validated by Parsely.js automatically while keeping the parsly.js message? I've accomplished this to a degree with the following library I've created which really is just a library full of regular expressions that replaces the improper characters by deleting them. A few examples of what that library looks like is here:

    //Regex to determine if the string is Alphanumeric (Both letters and numerals).  Deletes any values that don't fit the criteria.
    function hasNumbersAndLetters(input)
    {
        var regex = /[^a-zA-Z0-9\s-,]/gi;
        input.value = input.value.replace(regex, "");
    }

//Compares the string to a regex looking for numbers only, will remove any values that don't fit the regex.

    function onlyNumbers(input)
    {
        var regex = /[^0-9]/gi;
        input.value = input.value.replace(regex, "");
    }

These functions do in-fact work with the onblur event immediately after typing an improper value in the form being validated but cancel out the parsely.js message indicating why that is happening through its validation for being alphanumeric as an example.

This is an example of what one of my inputs looks like:

<input type="text" id="username" name="username" onblur="hasNumbersAndLetters(this)" data-parsley-type="alphanum" required=""  value="<?php if (!empty($username)) echo $username; ?>" />

If you can point me in the right direction it is appreciated.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parsley has not been designed with this in mind, and form validation in general does not work this way. You may be able to get away with this by listening to the field:error event and making your changes then, but the interface will suffer. I strongly recommend following community standards which do not "autocorrect" the inputs.

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!