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

188
Views
How to reject extra characters entered by the user?

In my HTML, I have an array of inputs. The user should be allowed to enter only one character in each. Here is its HTML:

<input class = "green" type="text" maxlength="1" />

The CSS for this is as follows:

input {
    font: 1.5em "Times New Roman", Times, serif; 
    width:0.9em; height: 0.9em;
    text-align:center; }
.green { 
    color: green; }

If the user enters a character and then tries to enter another, nothing should happen. However, in my design the user can enter any number of characters, even though the earlier characters are pushed to the left and only the last character is visible. When the focus leaves the input field, all extra characters disappear and only the first input character remain. How can I make sure that when the user tries to enter additional characters, they are ignored and nothing happens?

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

0

Is it what you need?

function go(v){
    if (v.value.length==0){
    return true;
  }
    return false;
}
<input class = "green" type="text" maxlength="1" onkeydown="return go(this)"/>

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!