![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
jquery.mobilephonenumber
Advanced tools
A general purpose library for validating and formatting mobile phone numbers.
A general purpose library for validating and formatting mobile phone numbers.
$('input.phone-num').mobilePhoneNumber();
You can bind to an event when the user changes the country of the phone number:
$('input.phone-num').bind('country.mobilePhoneNumber', function(e, country) {
console.log('The new country code:', country);
})
You can find a demo here.
Dependencies:
Enables phone number formatting.
Options:
defaultPrefix
: allows the user to type a phone number without the prefix for this specific value.Example:
$('input.phone-num').mobilePhoneNumber({
defaultPrefix: '+1'
});
Returns the phone number value with prefix, but without other formatting.
Example:
$('input.phone-num').val(); //=> '+1 (415) 123-5554'
$('input.phone-num').mobilePhoneNumber('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:
$('input.phone-num').val(); //=> '+1 (415) 123-5554'
$('input.phone-num').mobilePhoneNumber('validate'); //=> true
$('input.phone-num').val(); //=> '+43'
$('input.phone-num').mobilePhoneNumber('validate'); //=> false
Returns the two-letter country code of the phone number.
Example:
$('input.phone-num').val(); //=> '+32 495 12 34 56'
$('input.phone-num').mobilePhoneNumber('country'); //=> 'BE'
Returns the prefix of the phone number.
Example:
$('input.phone-num').val(); //=> '+32 495 12 34 56'
$('input.phone-num').mobilePhoneNumber('prefix'); //=> '+32'
Returns the formatted phone number.
Example:
$.formatMobilePhoneNumber('14151235554'); //=> '+1 (415) 123-5554'
Triggered when the country has changed.
Example:
$('input.phone-num').bind('country.mobilePhoneNumber', function(e, country) {
console.log('The new country code:', country);
})
// Simulate user input
$('input.phone-num').val('+32495123456').keyup();
//=> The new country code: BE
Run cake build
Run cake test
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 mobile phone numbers.
The npm package jquery.mobilephonenumber receives a total of 18 weekly downloads. As such, jquery.mobilephonenumber popularity was classified as not popular.
We found that jquery.mobilephonenumber demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.