Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ export class SurveyorMasks {
newModelVal = newModelVal.substring(0, newModelVal.length - 1);
}

if (newModelVal.length > 10) {
newModelVal = newModelVal.substring(0, 10);
if (newModelVal.length > 15) {
newModelVal = newModelVal.substring(0, 15);
}

return newModelVal;
Expand All @@ -36,8 +36,13 @@ export class SurveyorMasks {
newVal = value.replace(/^(\d{0,3})/, '($1)');
} else if (value.length <= 6) {
newVal = value.replace(/^(\d{0,3})(\d{0,3})/, '($1) $2');
} else {
} else if (value.length <= 10) {
newVal = value.replace(/^(\d{0,3})(\d{0,3})(.*)/, '($1) $2-$3');
} else {
const countryCodeLength = value.length - 10;
const countryCode = value.substring(0, countryCodeLength);
const remaining = value.substring(countryCodeLength);
newVal = '+' + countryCode + ' ' + remaining.replace(/^(\d{0,3})(\d{0,3})(.*)/, '($1) $2-$3');
}
return newVal;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class SurveyorValidators {

static isValidPhoneFormat(c: AbstractControl) {
const temp = (c.value || '').replace(/\D/g, '');
if (temp.length === 10 || temp.length === 0) {
if (temp.length === 0 || (temp.length >= 10 && temp.length <= 15)) {
return null;
} else {
return { invalidPhoneNumber: true };
Expand Down