Skip to content
Snippets Groups Projects
Commit 88b5124c authored by Chris Hallberg's avatar Chris Hallberg
Browse files

Phone number validation strings moved to layout.

parent a3521149
No related merge requests found
......@@ -85,19 +85,13 @@ function lessFacets(id) {
}
// Phone number validation
var libphoneTranslateCodes = ["libphonenumber_invalid", "libphonenumber_invalidcountry", "libphonenumber_invalidregion", "libphonenumber_notanumber", "libphonenumber_toolong", "libphonenumber_tooshort", "libphonenumber_tooshortidd"];
var libphoneErrorStrings = ["Phone number invalid", "Invalid country calling code", "Invalid region code", "The string supplied did not seem to be a phone number", "The string supplied is too long to be a phone number", "The string supplied is too short to be a phone number", "Phone number too short after IDD"];
function phoneNumberFormHandler(numID, regionCode) {
var phoneInput = document.getElementById(numID);
var number = phoneInput.value;
var valid = isPhoneNumberValid(number, regionCode);
if(valid != true) {
if(typeof valid === 'string') {
for(var i=libphoneErrorStrings.length;i--;) {
if(valid.match(libphoneErrorStrings[i])) {
valid = vufindString[libphoneTranslateCodes[i]];
}
}
valid = vufindString[valid];
} else {
valid = vufindString['libphonenumber_invalid'];
}
......
......@@ -30,6 +30,7 @@
// Deal with cart stuff:
if (!isset($this->renderingError)) {
// Add translation strings
$this->jsTranslations()->addStrings(
array(
'add_tag_success' => 'add_tag_success',
......@@ -49,6 +50,18 @@
'number_thousands_separator' => ['number_thousands_separator', null, ',']
)
);
// Add libphonenumber.js strings
$this->jsTranslations()->addStrings(
array(
"'Phone number invalid'" => 'libphonenumber_invalid',
"'Invalid country calling code'" => 'libphonenumber_invalidcountry',
"'Invalid region code'" => 'libphonenumber_invalidregion',
"'The string supplied did not seem to be a phone number'" => 'libphonenumber_notanumber',
"'The string supplied is too long to be a phone number'" => 'libphonenumber_toolong',
"'The string supplied is too short to be a phone number'" => 'libphonenumber_tooshort',
"'Phone number too short after IDD'" => 'libphonenumber_tooshortidd'
)
);
$cart = $this->cart();
if ($cart->isActive()) {
$this->headScript()->appendFile("vendor/cookies.js");
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment