Product
Socket Now Supports uv.lock Files
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
react-telephone-input
Advanced tools
React component for entering and validating international telephone numbers
IMP: From 3.*, the styles won't be included by default. Can use require('react-telephone-input/lib/withStyles')
to get the styles.
Inspired from the awesome jquery plugin for International Telephone Input.
This one is written as a reactjs component.
Live Demo here - http://unstack.in/react-telephone-input/
function handleInputChange(telNumber, selectedCountry) {
console.log('input changed. number: ', telNumber, 'selected country: ', selectedCountry);
}
// Use declaratively within another react components render method
var ReactTelInput = require('react-telephone-input');
// var ReactTelInput = require('react-telephone-input/lib/withStyles'), if you need the styles
<MyAwesomeReactComponent>
<ReactTelInput
defaultCountry="in"
flagsImagePath='/path/to/images/flags.png'
onChange={handleInputChange}
onBlur={handleInputBlur}
/>
</MyAwesomeReactComponent>
// or render standalone
var ReactTelInput = require('react-telephone-input');
React.render(<ReactTelInput
defaultCountry="in"
flagsImagePath='/path/to/images/flags.png'
onChange={handleInputChange}/>
onBlur={handleInputBlur}
document.getElementById('my-container'));
The component accepts other props to customize it -
Both the props have the same purpose - for setting the initial value of the input programatically.
See value
above.
true
by default. Setting it to false will turn off all auto formatting.
The component selects the country code of a country by default. You can change it by passing the iso2 name of a country. E.g. for United States, set defaultCountry
to 'us'.
If you don't want all countries to be shown in the dropdown list, you can pass an array of country iso2 names to be shown in the dropdown list.
Preferred countries show up in the top of the list. This prop also accepts an array of country iso2 names.
You can send in additional classes to be applied to the top container div of the component.
Function, which is called whenever there is a change of value in the input box.
Function, which is called when user presses the 'enter' key when the input box is in focus.
Function, which is called when the focus goes away from the input box.
Function, which is called when the input box gets the focus.
Boolean value. When set to true, the input box is disabled and clicking on flag dropdown does nothing.
String. This is passed on to the input field and works like it should for any other input field.
npm install
, you can just do var ReactTelephoneInput = require('react-telephone-input');
flagsImagePath
function handleInputChange(telNumber, selectedCountry) {
console.log('input changed. number: ', telNumber, 'selected country: ', selectedCountry);
}
function handleInputBlur(telNumber, selectedCountry) {
console.log('Focus off the ReactTelephoneInput component. Tel number entered is: ', telNumber, ' selected country is: ', selectedCountry);
}
<ReactTelephoneInput
defaultCountry='in'
flagsImagePath='/path/to/images/flags.png'
onChange={handleInputChange}
onBlur={handleInputBlur}
/>
The default value for flagsImagePath
is 'flags.png'
You can try the app by downloading everything and running the commands given below -
$ npm install
$ npm start
go to your browser and type `http://localhost:8000`
FAQs
React component for entering and validating international telephone numbers
The npm package react-telephone-input receives a total of 9,485 weekly downloads. As such, react-telephone-input popularity was classified as popular.
We found that react-telephone-input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.