Created
July 23, 2016 15:40
-
-
Save kamikaz1k/e844df614e33950d7d51e4f6a7ed6c76 to your computer and use it in GitHub Desktop.
Phone Number component validate input
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
... | |
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