
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
jquery.phone
Advanced tools
A general purpose library for validating and formatting phone numbers.
Basic Example:
$('#phone').phone();
You can bind to an event when the user changes the country of the phone number:
$('#phone').bind('phone.country', function(e, country) {
console.log('The new country code:', country);
});
This library is a fork from Stripe's outdated plugin.
Enables phone number formatting.
Enables phone number formatting, with the given options.
Available options:
defaultPrefix: Set the default prefix, default is +1value: Set the default value of the input.Example:
$('#phone').phone({
defaultPrefix: '+44',
value: '7700900680'
});
Returns the phone number value with prefix, but without other formatting.
Example:
//=> '+1 (415) 123-5554'
$('#phone').phone('val'); //=> '+14151235554'
Returns whether the phone number is valid.
Note: this implementation is very naive; it only validates that the phone number is longer than its prefix.
Example:
//=> '+1 (415) 123-5554'
$('#phone').phone('validate'); //=> true
//=> '+43'
$('#phone').phone('validate'); //=> false
Returns the two-letter country code of the phone number.
Example:
$('#phone').phone('country'); //=> 'BE'
Returns the prefix of the phone number.
Example:
$('#phone').val(); //=> '+32 495 12 34 56'
$('#phone').phone('prefix'); //=> '+32'
Returns the formatted phone number.
Example:
$.phone.formatPhone('14151235554'); //=> '+1 (415) 123-5554'
Triggered when the country has changed.
Example:
$('#phone').bind('phone.country', function(e, country) {
console.log('The new country code:', country);
})
// Simulate user input
$('#phone').val('+32495123456').keyup();
//=> The new country code: BE
Run grunt
We recommend you set the pattern, type, and x-autocompletetype attributes, which will trigger autocompletion and a numeric keypad to display on touch devices:
<input class="phone-num" type="tel" pattern="\d*" x-autocompletetype="tel">
You may have to turn off HTML5 validation (using the novalidate form attribute) when using this pattern, since it won't permit spaces and other characters that appear in the formatted version of the phone number.
FAQs
A general purpose library for validating and formatting phone numbers.
We found that jquery.phone 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.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.