在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):stripe-archive/jquery.mobilePhoneNumber开源软件地址(OpenSource Url):https://github.com/stripe-archive/jquery.mobilePhoneNumber开源编程语言(OpenSource Language):CoffeeScript 95.5%开源软件介绍(OpenSource Introduction):Project statusThis project is deprecated. We will patch jquery.mobilePhoneNumber for critical security issues, but won't be adding any new features. jQuery.mobilePhoneNumberA 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:
API$.fn.mobilePhoneNumber([options])Enables phone number formatting. Options:
Example: $("input.phone-num").mobilePhoneNumber({
defaultPrefix: "+1"
}); $.fn.mobilePhoneNumber('val')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' $.fn.mobilePhoneNumber('validate')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 $.fn.mobilePhoneNumber('country')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' $.fn.mobilePhoneNumber('prefix')Returns the prefix of the phone number. Example: $("input.phone-num").val(); //=> '+32 495 12 34 56'
$("input.phone-num").mobilePhoneNumber("prefix"); //=> '+32' $.formatMobilePhoneNumber(phone)Returns the formatted phone number. Example: $.formatMobilePhoneNumber("14151235554"); //=> '+1 (415) 123-5554' Eventscountry.mobilePhoneNumberTriggered 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 BuildingRun Running testsRun Mobile recommendationsWe recommend you set the <input class="phone-num" type="tel" pattern="\d*" x-autocompletetype="tel" /> You may have to turn off HTML5 validation (using the |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论