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

178
Views
How to add allowed symbols on input field in HTML?

I have my own create input tag which has to field for phone number:

    <base-input
        style="margin-bottom: 15px; width: 100%; max-width: 510px;"
        v-model="phone"
        type="tel"
        placeholder="Mobile phone"
    />

How can I add only allowed symbols (0-9 and +). I was trying to use pattern="[0-9]+", but it doesn't work. Also, as I know, it can be done with regular expressions, but I don't know how to use it here

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

0

Use the regex ^[0-9+]+$. It allows numbers and +

Example here

about 4 years ago · Juan Pablo Isaza Report

0

The HTML input tag has a pattern attribute that receives a RegEx.

for your case:

<input
style="margin-bottom: 15px; width: 100%; max-width: 510px;"
v-model="phone"
type="tel"
placeholder="Mobile phone" 
pattern="[0-9\+]+" title="Phone number - allowed symbols are (0-9 and +)" />

If the pattern does not match it will throw the title.

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!