react-number-format icon indicating copy to clipboard operation
react-number-format copied to clipboard

numbers in other keyboard's language isn't typed on input

Open atefehnaseri opened this issue 4 years ago • 5 comments

I use this component in my react-hook-form but when I'm typing numbers in Persian (Standard Keyboard) it isn't typed any number.

atefehnaseri avatar Apr 19 '21 07:04 atefehnaseri

you can use customNumerals={['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']} see this section https://github.com/s-yadav/react-number-format#custom-numeral

straxico avatar Oct 02 '21 11:10 straxico

I set up custom-numeral and still have the issue.

You might consider the fact that iOS users don't have Persian keyboard. So here are all possible options I can think of now.

  1. Convert any non Persian digit character (e.g. Arabic or Urdu) to Persian (or English) on change event.
const a2p = (s: string | null) => s?.replace(/[٠-٩]/g, (d) => "۰۱۲۳۴۵۶۷۸۹"["٠١٢٣٤٥٦٧٨٩".indexOf(d)]);
const a2e = (s: string | null) => s?.replace(/[٠-٩]/g, (d) => "٠١٢٣٤٥٦٧٨٩".indexOf(d));
  1. Configure your input to keep iOS user's keyboard consistent with other Users.

https://css-tricks.com/finger-friendly-numerical-inputs-with-inputmode

  1. Ask your user to change their keyboard politely.
import { object, string } from "yup";

export const Schema = object({
  feild: string()
    .required("وارد کردن این قسمت الزامی است")
    .matches(/[\u06F0-\u06F90-9]+/, "زبان خود را به فارسی یا انگلیسی تغییر دهید")
})

realamirhe avatar Mar 19 '22 06:03 realamirhe

fixed it #874

baravak avatar Dec 19 '24 09:12 baravak

The custom numeral's can be handled outside the lib, Example: https://s-yadav.github.io/react-number-format/docs/customization/#custom-numeral-example let me know if this is not working with keyboards.

s-yadav avatar Dec 25 '24 09:12 s-yadav

you can use customNumerals={['۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹']} see this section https://github.com/s-yadav/react-number-format#custom-numeral

not work , and the component haven't this prop

mammad-arvin avatar Jan 03 '25 15:01 mammad-arvin