diff --git a/releases/international-phone-number.js b/releases/international-phone-number.js index d537c65..c6b5f06 100644 --- a/releases/international-phone-number.js +++ b/releases/international-phone-number.js @@ -93,7 +93,15 @@ return element.intlTelInput("isValidNumber"); } } else { - return true; + if (element.intlTelInput("getSelectedCountryData").dialCode === value) { + return true; + } else { + if (!value) { + return true; + } else { + return element.intlTelInput("isValidNumber"); + } + } } }; element.on('blur keyup change', function(event) { diff --git a/releases/international-phone-number.min.js b/releases/international-phone-number.min.js index ba65b36..28e2859 100644 --- a/releases/international-phone-number.min.js +++ b/releases/international-phone-number.min.js @@ -1,2 +1,2 @@ /*! international-phone-number 2015-07-10 */ -(function(){"use strict";angular.module("internationalPhoneNumber",[]).directive("internationalPhoneNumber",["$timeout",function(a){return{restrict:"A",require:"^ngModel",scope:{ngModel:"=",defaultCountry:"@"},link:function(b,c,d,e){var f,g,h,i;return e&&""!==c.val()&&a(function(){return c.intlTelInput("setNumber",c.val()),e.$setViewValue(c.val())},0),h=function(){return e.$setViewValue(c.val())},f=function(a){return a instanceof Array?a:a.toString().replace(/[ ]/g,"").split(",")},g={autoFormat:!0,autoHideDialCode:!0,defaultCountry:"",nationalMode:!1,numberType:"",onlyCountries:void 0,preferredCountries:["us","gb"],responsiveDropdown:!1,utilsScript:""},angular.forEach(g,function(a,b){var c;if(d.hasOwnProperty(b)&&angular.isDefined(d[b]))return c=d[b],"preferredCountries"===b?g.preferredCountries=f(c):"onlyCountries"===b?g.onlyCountries=f(c):"boolean"==typeof a?g[b]="true"===c:g[b]=c}),i=b.$watch("ngModel",function(a){return b.$$postDigest(function(){return g.defaultCountry=b.defaultCountry,null!==a&&void 0!==a&&""!==a&&c.val(a),c.intlTelInput(g),void 0!==d.skipUtilScriptDownload||g.utilsScript||c.intlTelInput("loadUtils","/bower_components/intl-tel-input/lib/libphonenumber/build/utils.js"),i()})}),e.$formatters.push(function(b){return b?(a(function(){return c.intlTelInput("setNumber",b)},0),c.val()):b}),e.$parsers.push(function(a){return a?a.replace(/[^\d]/g,""):a}),e.$validators.internationalPhoneNumber=function(a){return c.attr("required")?a?c.intlTelInput("isValidNumber"):!1:!0},c.on("blur keyup change",function(a){return b.$apply(h)}),c.on("$destroy",function(){return c.intlTelInput("destroy"),c.off("blur keyup change")})}}}])}).call(this); \ No newline at end of file +(function(){"use strict";angular.module("internationalPhoneNumber",[]).directive("internationalPhoneNumber",["$timeout",function(a){return{restrict:"A",require:"^ngModel",scope:{ngModel:"=",defaultCountry:"@"},link:function(b,c,d,e){var f,g,h,i;return e&&""!==c.val()&&a(function(){return c.intlTelInput("setNumber",c.val()),e.$setViewValue(c.val())},0),h=function(){return e.$setViewValue(c.val())},f=function(a){return a instanceof Array?a:a.toString().replace(/[ ]/g,"").split(",")},g={autoFormat:!0,autoHideDialCode:!0,defaultCountry:"",nationalMode:!1,numberType:"",onlyCountries:void 0,preferredCountries:["us","gb"],responsiveDropdown:!1,utilsScript:""},angular.forEach(g,function(a,b){var c;if(d.hasOwnProperty(b)&&angular.isDefined(d[b]))return c=d[b],"preferredCountries"===b?g.preferredCountries=f(c):"onlyCountries"===b?g.onlyCountries=f(c):"boolean"==typeof a?g[b]="true"===c:g[b]=c}),i=b.$watch("ngModel",function(a){return b.$$postDigest(function(){return g.defaultCountry=b.defaultCountry,null!==a&&void 0!==a&&""!==a&&c.val(a),c.intlTelInput(g),void 0!==d.skipUtilScriptDownload||g.utilsScript||c.intlTelInput("loadUtils","/bower_components/intl-tel-input/lib/libphonenumber/build/utils.js"),i()})}),e.$formatters.push(function(b){return b?(a(function(){return c.intlTelInput("setNumber",b)},0),c.val()):b}),e.$parsers.push(function(a){return a?a.replace(/[^\d]/g,""):a}),e.$validators.internationalPhoneNumber=function(a){return c.attr("required")?a?c.intlTelInput("isValidNumber"):!1:c.intlTelInput("getSelectedCountryData").dialCode===a?!0:a?c.intlTelInput("isValidNumber"):!0},c.on("blur keyup change",function(a){return b.$apply(h)}),c.on("$destroy",function(){return c.intlTelInput("destroy"),c.off("blur keyup change")})}}}])}).call(this); \ No newline at end of file diff --git a/src/international-phone-number.coffee b/src/international-phone-number.coffee index 6393411..1633f07 100644 --- a/src/international-phone-number.coffee +++ b/src/international-phone-number.coffee @@ -92,7 +92,13 @@ angular.module("internationalPhoneNumber", []).directive 'internationalPhoneNumb else return element.intlTelInput("isValidNumber") else - return true + if element.intlTelInput("getSelectedCountryData").dialCode == value + return true + else + if !value + return true + else + return element.intlTelInput("isValidNumber") element.on 'blur keyup change', (event) ->