react-intl-tel-input icon indicating copy to clipboard operation
react-intl-tel-input copied to clipboard

Add a 'formatter' props to allow users to format numbers as they please

Open adrienharnay opened this issue 8 years ago • 2 comments

Hey,

I'd like to format my numbers using the google libphonenumber, but unfortunately I can't. Could you please add a prop to allow us to format the number? e.g.:

class TelInput extends Component {
  static propTypes = {
    [...]
    formatter: PropTypes.func,
  };

  render() {
    return (
      <input type="tel" autoComplete="off"
        [...]
        value={this.props.formatter ? this.props.formatter(this.props.value) : this.props.value}
      />
    );
  }
}

export default TelInput;

Thanks in advance!

adrienharnay avatar Oct 28 '16 09:10 adrienharnay

It would also be nice to have an onPhoneNumberFocus prop to match onPhoneNumberBlur.

adrienharnay avatar Oct 28 '16 11:10 adrienharnay

I too would like to do the same. Namely to remove the +52 or +1 prefix from the numbers (as I want that country code in the flag-box).

psiie avatar Nov 03 '17 23:11 psiie