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

161
Views
Input[type = 'text'] accept alphabets only instead of alphabets and whitespaces

I want to make my input text field accept alphabets only and space(at least one white space), not only alphabets, i use this expression but only alphabets works but if I put spaces between the text, doesnt work.

const isAlphabet = (input) => {
    const re = /^[a-zA-Z]+$/;
    return re.test(input);
  }
``
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

let change /^[a-zA-Z]+$/ for /^[a-z A-Z]+$/. i saw that someone used \s instead of , so i'm still sending my answer, since expression proposed by me is shorter, better performing (due to handling only space) plus u will gain additional knowledge, how to handle spaces in different way.

about 4 years ago · Juan Pablo Isaza Report

0

Use \s (including space, tab, form feed, line feed, and other Unicode spaces)

const isAlphabet = (input) => {
    const re = /^[a-zA-Z\s]+$/;
    return re.test(input);
}
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!