Skip to content

Instantly share code, notes, and snippets.

@kamikaz1k
Created July 23, 2016 15:40
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/e844df614e33950d7d51e4f6a7ed6c76 to your computer and use it in GitHub Desktop.
Save kamikaz1k/e844df614e33950d7d51e4f6a7ed6c76 to your computer and use it in GitHub Desktop.
Phone Number component validate input
{
...
scope.validateInput = function validateInput(fieldId) {
var phone = scope.phone;
// Validate input for US/CA Form
if (/US|CA/.test(scope.countryCode)) {
// If all the model values have values,
// then update the parent model
if (phone.areaCode && phone.areaCode &&
phone.phoneOne && phone.phoneTwo) {
scope.parentModel = phone.countryCode +
phone.areaCode +
phone.phoneOne +
phone.phoneTwo;
}
// Otherwise the parent model should be emptied because
// the inputs are invalid
else {
scope.parentModel = "";
}
}
// Validate input for International Form
else {
// If the internal model holds a value,
// then update the parent model
if (phone.international) {
scope.parentModel = phone.international;
}
// Otherwise the parent model should be emptied
else {
scope.parentModel = "";
}
}
...
}
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment