Skip to content

Instantly share code, notes, and snippets.

@kamikaz1k
Created July 23, 2016 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kamikaz1k/bdfcad3dbb341b30164e4136c50de375 to your computer and use it in GitHub Desktop.
Save kamikaz1k/bdfcad3dbb341b30164e4136c50de375 to your computer and use it in GitHub Desktop.
Phone Number form validation
function validateInput(fieldId) {
if (/US|CA/.test(scope.countryCode)) {
...
// pass
ngModelCtrl.$setValidity("validPhone", true);
scope.parentModel = phone.international;
...
// fail
ngModelCtrl.$setValidity("validPhone", false);
scope.parentModel = "";
...
} else {
...
// pass
ngModelCtrl.$setValidity("validPhone", true);
scope.parentModel = phone.international;
...
// fail
ngModelCtrl.$setValidity("validPhone", false);
scope.parentModel = "";
...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment