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

107
Views
event on minimum length using js

need to add error text by using js - If user type only 3 character in the field. How to do it? Thanks

<body>
<input type="text" class="user-input" minlength="4">
</body>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can use the pattern attribute validation.

 <input pattern=".{3,}"   required title="3 characters minimum">
<input pattern=".{5,10}" required title="5 to 10 characters">

If you want to create the option to use the pattern for "empty, or minimum length" use like below

<input pattern=".{0}|.{5,10}" required title="Either 0 OR (5 to 10 chars)">
<input pattern=".{0}|.{8,}"   required title="Either 0 OR (8 chars minimum)">
about 4 years ago · Juan Pablo Isaza Report

0

you could retrieve its value from the id:

        let x = document.getElementsByClassName['user-input'].value;

        if (x.length < 4) {
            alert(`please enter at least ${x.length} characters`);
            return false;
        }
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!