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

157
Views
Prevent pressing dot key in React Native numeric type keyboard

I developed an application where user can enter their mobile numbers and I want to prevent users from pressing the dot and dash key, How can I achieve it?

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

0

you can use react-phone-number-input

import React, { useState } from 'react'
import PhoneInput from 'react-phone-number-input/react-native-input'

function Example() {
  const [value, setValue] = useState()
  return (
    <PhoneInput
      style={...}
      defaultCountry="US"
      value={value}
      onChange={setValue} />
  )
}

see here demo

To display number phone you can use formater


import { formatPhoneNumber } from 'react-phone-number-input'
formatPhoneNumber('+12133734253') === '(213) 373-4253'

then put in text

<Text>
  {formatPhoneNumber('+12133734253')}
</Text>
about 4 years ago · Juan Pablo Isaza Report

0

For the sake of not integrating a third party package just to check the phone number, you can simply create a regex that matches dot and dash keys and show a message "Please don't use "-" and "." while users are entering their phone number. This solution will provide more space for you to tweak things later if the needs from this component changes.

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!