/*jslint vars: true, undef: true, browser: true, plusplus: true, indent: 4 */
/*global jQuery, $, Modernizr, Placeholder, window, Lectric, helpers, methods */
/**
* Validation ruiles for Item - Edit
*/
// Set labels for all input/select/textarea
$('.fieldLabel').each(function() {
var fieldId = $(this).closest('tr').find('input, select, textarea').attr('id');
if (fieldId) {
$(this).html('');
if ($(this).find('.required').length > 0) {
$("#" + fieldId).addClass('required');
}
}
});
// Set labels for all checkboxes
var checkBoxNr = 0;
$('.checkbox_wrap').each(function() {
var fieldId = 'checkBox_' + checkBoxNr++;
$(this).find('input').attr('id', fieldId);
$(this).find('label').attr('for', fieldId);
});
// Define all field rules available
allFormRules = [
// Using names from example 1
{
name: 'First Name',
display: 'first name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'Last Name',
display: 'last name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'Email',
display: 'e-mail',
rules: 'valid_email|max_length[100]'
},
{
name: 'Company Name',
display: 'company name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'Country',
display: 'country',
rules: 'callback_set_area|max_length[100]'
},
{
name: 'Address line 1',
display: 'address line 1',
rules: 'max_length[100]'
},
{
name: 'Address line 2',
display: 'address line 2',
rules: 'max_length[100]'
},
{
name: 'City',
display: 'city',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'State',
display: 'state',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'Zip Code',
display: 'zip code',
rules: 'callback_western_character|max_length[50]'
},
{
name: 'Industry',
display: 'industry',
rules: ''
},
{
name: 'Department',
display: 'department',
rules: ''
},
{
name: 'Role',
display: 'role',
rules: ''
},
{
name: 'job_title',
display: 'job title',
rules: 'callback_western_character|max_length[75]'
},
{
name: 'Work Phone',
display: 'work phone',
rules: 'callback_crm_phone|max_length[50]'
},
{
name: 'Mobile Phone',
display: 'mobile phone',
rules: 'integer|max_length[50]'
},
{
name: 'Comments',
display: 'comments',
rules: 'callback_western_character|max_length[30]'
},
{
name: 'Self Updated', // Either a checkbox or hidden field in SP
display: 'consent',
rules: 'required'
},
// Using columnnames as in the popup examples
{
name: 'COLUMN9',
display: 'first name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'COLUMN10',
display: 'last name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'EMAIL',
display: 'e-mail',
rules: 'valid_email|max_length[100]'
},
{
name: 'COLUMN27',
display: 'company name',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'COLUMN17',
display: 'country',
rules: 'callback_set_area|max_length[100]'
},
{
name: 'COLUMN12',
display: 'address line 1',
rules: 'max_length[100]'
},
{
name: 'COLUMN13',
display: 'address line 2',
rules: 'max_length[100]'
},
{
name: 'COLUMN14',
display: 'city',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'COLUMN15',
display: 'state',
rules: 'callback_western_character|max_length[100]'
},
{
name: 'COLUMN16',
display: 'zip code',
rules: 'callback_western_character|max_length[50]'
},
{
name: 'COLUMN5',
display: 'industry',
rules: ''
},
{
name: 'COLUMN21',
display: 'department',
rules: ''
},
{
name: 'COLUMN43',
display: 'role',
rules: ''
},
{
name: 'COLUMN18',
display: 'work phone',
rules: 'callback_crm_phone|max_length[50]'
},
{
name: 'COLUMN19',
display: 'mobile phone',
rules: 'integer|max_length[50]'
},
{
name: 'COLUMN42',
display: 'comments',
rules: 'callback_western_character|max_length[1000]'
},
{
name: 'COLUMN72',
display: 'topic',
rules: 'callback_set_area'
}
];
currentFormRules = [];
// Get all rules for the current form from all rules array
var ruleNo = 0;
for (var i = 0; i < allFormRules.length; i++) {
var rule = allFormRules[i];
var fieldName = '[name="' + rule.name + '"]';
if ($(fieldName).length > 0) {
// If the field has class required we add required rule to it
if ($(fieldName).hasClass('required')) {
rule.rules = (rule.rules) ? 'required|' + rule.rules : 'required';
}
currentFormRules[ruleNo++] = rule;
}
}
// Get form by name 'nameOfForm', by id '#idOfForm' or leave empty ''
var formToValidate = '';
// If no form name/id defined we find the first form available
if (formToValidate === "") {
formToValidate = document.forms[0];
}
// Initialize the form validator
var validator = new FormValidator(formToValidate, currentFormRules, { validateOnChange: true}, function(errors, event, singleField) {
// Handle a form submit or a single field change
if (singleField) {
errorReporting($(formToValidate), errors, false);
} else {
errorReporting($(formToValidate), errors, true);
}
});
/**
* Displays error message and highlight fields (requires jQuery)
* @param {string} name Form name attribute
* @param {array} errors validate.js errors
* @return {void}
*/
function errorReporting (form, errors, doFocus) {
// Remove existing error messages
form.find('input, select, textarea').removeClass('error');
form.find('input, select, textarea').closest('td').removeClass('error');
form.find('input, select, textarea').siblings('.field-error').remove();
if (errors.length > 0) {
for (var i = 0, errorLength = errors.length; i < errorLength; i++) {
// Focus on first error field
if (doFocus === true && i === 0) {
$("#" + errors[i].id).focus();
}
var id = "#" + errors[i].id;
var label = $('label[for=' + errors[i].id + ']');
// Add error class on field and after the field
$(id).addClass("error");
$(id).closest("td").addClass("error");
$(id).after('
' + errors[i].message + '
');
}
}
}
/**
* Check for a valid characters where only Western europe characters are allowed
* @param {string} value Input
* @return {bool}
*/
validator.registerCallback('western_character', function(value) {
if (value === "") {
return true;
}
if (/[a-zA-Z0-9\xc0-\xff]/.test(value)) {
return true;
}
return false;
});
/**
* Check work phone format has CRM format
* @param {string} value Input
* @return {bool}
*/
validator.registerCallback('crm_phone', function(value) {
if (value === "") {
return true;
}
if (/^\+\d+\ \d+$/.test(value)) {
return true;
}
return false;
});
/**
* Translate country selection to Area for alerting correct sales person
* @param {string} value Input
* @return {bool}
*/
validator.registerCallback('set_area', function(value) {
var topic = ""; // The business or topic chosen in the form
if ($('select[name="COLUMN72"]').length > 0 ) topic = $('select[name="COLUMN72"]').val();
else if ($('input[name="COLUMN72"]').length > 0 ) topic = $('input[name="COLUMN72"]').val();
var area = new Array();
if (topic == "Government") { // Gov has different region names
area["Afghanistan"]="ECT";
area["Albania"]="ECT";
area["Algeria"]="LAM";
area["American Samoa"]="NORAM";
area["Andorra"]="ECT";
area["Angola"]="LAM";
area["Anguilla"]="ECT";
area["Antarctica"]="ASIA";
area["Antigua and Barbuda"]="LAM";
area["Argentina"]="LAM";
area["Armenia"]="ECT";
area["Aruba"]="LAM";
area["Australia"]="ASIA";
area["Austria"]="ECT";
area["Azerbaijan"]="ECT";
area["Bahamas"]="LAM";
area["Bahrain"]="ME";
area["Bangladesh"]="ASIA";
area["Barbados"]="LAM";
area["Belarus"]="ECT";
area["Belgium"]="ECT";
area["Belize"]="LAM";
area["Benin"]="LAM";
area["Bermuda"]="LAM";
area["Bhutan"]="ASIA";
area["Bolivia"]="LAM";
area["Bosnia and Herzegovina"]="ECT";
area["Botswana"]="LAM";
area["Bouvet Island"]="ECT";
area["Brazil"]="LAM";
area["British Indian Ocean Territory"]="ECT";
area["Brunei Darussalam"]="ASIA";
area["Bulgaria"]="ECT";
area["Burkina Faso"]="LAM";
area["Burundi"]="LAM";
area["Cambodia"]="ASIA";
area["Cameroon"]="LAM";
area["Canada"]="NORAM";
area["Cape Verde"]="LAM";
area["Cayman Islands"]="LAM";
area["Central African Republic"]="LAM";
area["Chad"]="LAM";
area["Chile"]="LAM";
area["China"]="ASIA";
area["Christmas Island"]="ASIA";
area["Cocos (Keeling) Islands"]="ASIA";
area["Colombia"]="LAM";
area["Comoros"]="LAM";
area["Congo"]="LAM";
area["Congo, The Democratic Republic"]="LAM";
area["Cook Islands"]="ASIA";
area["Costa Rica"]="LAM";
area["Cote d'Ivoire"]="LAM";
area["Croatia"]="ECT";
area["Cuba"]="LAM";
area["Cyprus"]="ECT";
area["Czech Republic"]="ECT";
area["Denmark"]="ECT";
area["Djibouti"]="LAM";
area["Dominica"]="LAM";
area["Dominican Republic"]="LAM";
area["East Timor"]="ASIA";
area["Ecuador"]="LAM";
area["Egypt"]="ME";
area["El Salvador"]="LAM";
area["Equatorial Guinea"]="LAM";
area["Eritrea"]="LAM";
area["Estonia"]="ECT";
area["Ethiopia"]="LAM";
area["Falkland Islands (Malvinas)"]="ECT";
area["Faroe Islands"]="ECT";
area["Fiji"]="ASIA";
area["Finland"]="ECT";
area["France"]="ECT";
area["French Guiana"]="ECT";
area["French Polynesia"]="ECT";
area["French Southern Territories"]="ECT";
area["Gabon"]="LAM";
area["Gambia"]="LAM";
area["Georgia"]="ECT";
area["Germany"]="ECT";
area["Ghana"]="LAM";
area["Gibraltar"]="ECT";
area["Greece"]="ECT";
area["Greenland"]="ECT";
area["Grenada"]="LAM";
area["Guadeloupe"]="ECT";
area["Guam"]="NORAM";
area["Guatemala"]="LAM";
area["Guinea"]="LAM";
area["Guinea-Bissau"]="LAM";
area["Guyana"]="LAM";
area["Haiti"]="LAM";
area["Heard Island McDonald Islands"]="ASIA";
area["Holy See (Vatican City State)"]="ECT";
area["Honduras"]="LAM";
area["Hong Kong"]="ASIA";
area["Hungary"]="ECT";
area["Iceland"]="ECT";
area["India"]="ASIA";
area["Indonesia"]="ASIA";
area["Iran, Islamic Republic of"]="ME";
area["Iraq"]="ME";
area["Ireland"]="ECT";
area["Israel"]="ECT";
area["Italy"]="ECT";
area["Jamaica"]="LAM";
area["Japan"]="ASIA";
area["Jordan"]="ME";
area["Kazakhstan"]="ECT";
area["Kenya"]="LAM";
area["Kiribati"]="ASIA";
area["Korea, Democratic People's Rep"]="ASIA";
area["Korea, Republic of"]="ASIA";
area["Kuwait"]="ME";
area["Kyrgyzstan"]="ECT";
area["Lao People's Democratic Rep"]="ASIA";
area["Latvia"]="ECT";
area["Lebanon"]="ME";
area["Lesotho"]="LAM";
area["Liberia"]="LAM";
area["Libyan Arab Jamahiriya"]="LAM";
area["Liechtenstein"]="ECT";
area["Lithuania"]="ECT";
area["Luxembourg"]="ECT";
area["Macau"]="ASIA";
area["Macedonia"]="ECT";
area["Madagascar"]="LAM";
area["Malawi"]="LAM";
area["Malaysia"]="ASIA";
area["Maldives"]="ASIA";
area["Mali"]="LAM";
area["Malta"]="ECT";
area["Marshall Islands"]="ASIA";
area["Martinique"]="ECT";
area["Mauritania"]="LAM";
area["Mauritius"]="LAM";
area["Mayotte"]="ECT";
area["Mexico"]="LAM";
area["Micronesia (Federated states)"]="ASIA";
area["Moldova, Republic of"]="ECT";
area["Monaco"]="ECT";
area["Mongolia"]="ECT";
area["Montserrat"]="ECT";
area["Morocco"]="LAM";
area["Mozambique"]="LAM";
area["Myanmar"]="ASIA";
area["Namibia"]="LAM";
area["Nauru"]="ASIA";
area["Nepal"]="ASIA";
area["Netherlands Antilles"]="LAM";
area["Netherlands"]="ECT";
area["New Caledonia"]="ECT";
area["New Zealand"]="ASIA";
area["Nicaragua"]="LAM";
area["Niger"]="LAM";
area["Nigeria"]="LAM";
area["Niue"]="ASIA";
area["Norfolk Island"]="ASIA";
area["Northern Mariana Islands"]="ASIA";
area["Norway"]="ECT";
area["Oman"]="ME";
area["Pakistan"]="ECT";
area["Palau"]="ASIA";
area["Palestinian Territory, Occup"]="ME";
area["Panama"]="LAM";
area["Papua New Guinea"]="ASIA";
area["Paraguay"]="LAM";
area["Peru"]="LAM";
area["Philippines"]="ASIA";
area["Pitcairn"]="ECT";
area["Poland"]="ECT";
area["Portugal"]="ECT";
area["Puerto Rico"]="NORAM";
area["Qatar"]="ME";
area["Republic of Montenegro"]="ECT";
area["Republic of Serbia"]="ECT";
area["Reunion"]="ECT";
area["Romania"]="ECT";
area["Russian Federation"]="ECT";
area["Rwanda"]="LAM";
area["Saint Helena"]="ECT";
area["Saint Kitts and Nevis"]="LAM";
area["Saint Lucia"]="LAM";
area["Saint Pierre and Miquelon"]="ECT";
area["Samoa"]="ASIA";
area["San Marino"]="ECT";
area["Sao Tome and Principe"]="ECT";
area["Saudi Arabia"]="ME";
area["Senegal"]="LAM";
area["Seychelles"]="LAM";
area["Sierra Leone"]="LAM";
area["Singapore"]="ASIA";
area["Slovakia"]="ECT";
area["Slovenia"]="ECT";
area["Solomon Islands"]="ASIA";
area["Somalia"]="LAM";
area["South Africa"]="LAM";
area["South Georgia and the South Sa"]="ECT";
area["South Sudan"]="LAM";
area["Spain"]="ECT";
area["Sri Lanka"]="ASIA";
area["St Vincent and Grenadines"]="LAM";
area["Sudan"]="LAM";
area["Suriname"]="LAM";
area["Svalbard and Jan Mayen"]="ECT";
area["Swaziland"]="LAM";
area["Sweden"]="ECT";
area["Switzerland"]="ECT";
area["Syrian Arab Republic"]="ME";
area["Taiwan"]="ASIA";
area["Tajikistan"]="ECT";
area["Tanzania, United Republic of"]="LAM";
area["Thailand"]="ASIA";
area["Togo"]="LAM";
area["Tokelau"]="ASIA";
area["Tonga"]="ASIA";
area["Trinidad and Tobago"]="LAM";
area["Tunisia"]="LAM";
area["Turkey"]="ECT";
area["Turkmenistan"]="ECT";
area["Turks and Caicos Islands"]="ECT";
area["Tuvalu"]="ASIA";
area["Uganda"]="LAM";
area["Ukraine"]="ECT";
area["United Arab Emirates"]="ME";
area["United Kingdom"]="ECT";
area["US Minor Outlying Is"]="NORAM";
area["United States Minor Outlying I"]="NORAM";
area["United States"]="NORAM";
area["Uruguay"]="LAM";
area["Uzbekistan"]="ECT";
area["Vanuatu"]="ECT";
area["Venezuela"]="LAM";
area["Viet Nam"]="ASIA";
area["Virgin Islands (British)"]="ECT";
area["Virgin Islands, British"]="ECT";
area["Virgin Islands, U.S."]="NORAM";
area["Wallis and Futuna Islands"]="ECT";
area["Western Sahara"]="LAM";
area["Yemen"]="ME";
area["Zambia"]="LAM";
area["Zimbabwe"]="LAM";
}
else {
area["Afghanistan"]="AME";
area["Albania"]="EMC";
area["Algeria"]="EMC";
area["American Samoa"]="ASIA";
area["Andorra"]="EMC";
area["Angola"]="AME";
area["Anguilla"]="LATAM";
area["Antarctica"]="EMEA";
area["Antigua and Barbuda"]="LATAM";
area["Argentina"]="LATAM";
area["Armenia"]="EMC";
area["Aruba"]="LATAM";
area["Australia"]="SAJ";
area["Austria"]="EMC";
area["Azerbaijan"]="EMC";
area["Bahamas"]="NORAM";
area["Bahrain"]="AME";
area["Bangladesh"]="SAJ";
area["Barbados"]="LATAM";
area["Belarus"]="EMC";
area["Belgium"]="EMC";
area["Belize"]="LATAM";
area["Benin"]="AME";
area["Bermuda"]="NORAM";
area["Bhutan"]="SAJ";
area["Bolivia"]="LATAM";
area["Bosnia and Herzegovina"]="EMC";
area["Botswana"]="AME";
area["Bouvet Island"]="EMEA";
area["Brazil"]="LATAM";
area["British Indian Ocean Territory"]="ASIA";
area["Brunei Darussalam"]="SAJ";
area["Bulgaria"]="EMC";
area["Burkina Faso"]="AME";
area["Burundi"]="AME";
area["Cambodia"]="SAJ";
area["Cameroon"]="AME";
area["Canada"]="NORAM";
area["Cape Verde"]="AME";
area["Cayman Islands"]="LATAM";
area["Central African Republic"]="AME";
area["Chad"]="AME";
area["Chile"]="LATAM";
area["China"]="GCK";
area["Christmas Island"]="SAJ";
area["Cocos (Keeling) Islands"]="SAJ";
area["Colombia"]="LATAM";
area["Comoros"]="AME";
area["Congo"]="AME";
area["Congo, The Democratic Republic"]="AME";
area["Cook Islands"]="SAJ";
area["Costa Rica"]="LATAM";
area["Cote d'Ivoire"]="AME";
area["Croatia"]="EMC";
area["Cuba"]="LATAM";
area["Cyprus"]="EMC";
area["Czech Republic"]="EMC";
area["Denmark"]="EMC";
area["Djibouti"]="AME";
area["Dominica"]="LATAM";
area["Dominican Republic"]="LATAM";
area["East Timor"]="ASIA";
area["Ecuador"]="LATAM";
area["Egypt"]="AME";
area["El Salvador"]="LATAM";
area["Equatorial Guinea"]="AME";
area["Eritrea"]="AME";
area["Estonia"]="EMC";
area["Ethiopia"]="AME";
area["Falkland Islands (Malvinas)"]="LATAM";
area["Faroe Islands"]="EMC";
area["Fiji"]="SAJ";
area["Finland"]="EMC";
area["France"]="EMC";
area["French Guiana"]="EMC";
area["French Polynesia"]="SAJ";
area["French Southern Territories"]="EMEA";
area["Gabon"]="AME";
area["Gambia"]="AME";
area["Georgia"]="EMC";
area["Germany"]="EMC";
area["Ghana"]="AME";
area["Gibraltar"]="EMC";
area["Greece"]="EMC";
area["Greenland"]="EMC";
area["Grenada"]="LATAM";
area["Guadeloupe"]="EMC";
area["Guam"]="NORAM";
area["Guatemala"]="LATAM";
area["Guinea"]="AME";
area["Guinea-Bissau"]="AME";
area["Guyana"]="LATAM";
area["Haiti"]="LATAM";
area["Heard Island McDonald Islands"]="SAJ";
area["Holy See (Vatican City State)"]="EMC";
area["Honduras"]="LATAM";
area["Hong Kong"]="GCK";
area["Hungary"]="EMC";
area["Iceland"]="EMC";
area["India"]="SAJ";
area["Indonesia"]="SAJ";
area["Iran, Islamic Republic of"]="AME";
area["Iraq"]="AME";
area["Ireland"]="EMC";
area["Israel"]="EMC";
area["Italy"]="EMC";
area["Jamaica"]="LATAM";
area["Japan"]="SAJ";
area["Jordan"]="AME";
area["Kazakhstan"]="EMC";
area["Kenya"]="AME";
area["Kiribati"]="SAJ";
area["Korea, Democratic People's Rep"]="GCK";
area["Korea, Republic of"]="GCK";
area["Kuwait"]="AME";
area["Kyrgyzstan"]="EMC";
area["Lao People's Democratic Rep"]="SAJ";
area["Latvia"]="EMC";
area["Lebanon"]="AME";
area["Lesotho"]="AME";
area["Liberia"]="AME";
area["Libyan Arab Jamahiriya"]="EMC";
area["Liechtenstein"]="EMC";
area["Lithuania"]="EMC";
area["Luxembourg"]="EMC";
area["Macau"]="GCK";
area["Macedonia"]="EMC";
area["Madagascar"]="AME";
area["Malawi"]="AME";
area["Malaysia"]="SAJ";
area["Maldives"]="SAJ";
area["Mali"]="AME";
area["Malta"]="EMC";
area["Marshall Islands"]="SAJ";
area["Martinique"]="EMC";
area["Mauritania"]="EMC";
area["Mauritius"]="AME";
area["Mayotte"]="AME";
area["Mexico"]="LATAM";
area["Micronesia (Federated states)"]="SAJ";
area["Moldova, Republic of"]="EMC";
area["Monaco"]="EMC";
area["Mongolia"]="EMC";
area["Montserrat"]="LATAM";
area["Morocco"]="EMC";
area["Mozambique"]="AME";
area["Myanmar"]="SAJ";
area["Namibia"]="AME";
area["Nauru"]="SAJ";
area["Nepal"]="SAJ";
area["Netherlands Antilles"]="LATAM";
area["Netherlands"]="EMC";
area["New Caledonia"]="SAJ";
area["New Zealand"]="SAJ";
area["Nicaragua"]="LATAM";
area["Niger"]="AME";
area["Nigeria"]="AME";
area["Niue"]="SAJ";
area["Norfolk Island"]="SAJ";
area["Northern Mariana Islands"]="SAJ";
area["Norway"]="EMC";
area["Oman"]="AME";
area["Pakistan"]="AME";
area["Palau"]="SAJ";
area["Palestinian Territory, Occup"]="AME";
area["Panama"]="LATAM";
area["Papua New Guinea"]="SAJ";
area["Paraguay"]="LATAM";
area["Peru"]="LATAM";
area["Philippines"]="SAJ";
area["Pitcairn"]="LATAM";
area["Poland"]="EMC";
area["Portugal"]="EMC";
area["Puerto Rico"]="LATAM";
area["Qatar"]="AME";
area["Republic of Montenegro"]="EMC";
area["Republic of Serbia"]="EMC";
area["Reunion"]="EMC";
area["Romania"]="EMC";
area["Russian Federation"]="EMC";
area["Rwanda"]="AME";
area["Saint Helena"]="EMEA";
area["Saint Kitts and Nevis"]="LATAM";
area["Saint Lucia"]="LATAM";
area["Saint Pierre and Miquelon"]="NORAM";
area["Samoa"]="SAJ";
area["San Marino"]="EMC";
area["Sao Tome and Principe"]="EMEA";
area["Saudi Arabia"]="AME";
area["Senegal"]="AME";
area["Seychelles"]="AME";
area["Sierra Leone"]="AME";
area["Singapore"]="SAJ";
area["Slovakia"]="EMC";
area["Slovenia"]="EMC";
area["Solomon Islands"]="SAJ";
area["Somalia"]="AME";
area["South Africa"]="AME";
area["South Georgia and the South Sa"]="LATAM";
area["South Sudan"]="AME";
area["Spain"]="EMC";
area["Sri Lanka"]="SAJ";
area["St Vincent and Grenadines"]="LATAM";
area["Sudan"]="AME";
area["Suriname"]="LATAM";
area["Svalbard and Jan Mayen"]="EMEA";
area["Swaziland"]="AME";
area["Sweden"]="EMC";
area["Switzerland"]="EMC";
area["Syrian Arab Republic"]="AME";
area["Taiwan"]="GCK";
area["Tajikistan"]="EMC";
area["Tanzania, United Republic of"]="AME";
area["Thailand"]="SAJ";
area["Togo"]="AME";
area["Tokelau"]="SAJ";
area["Tonga"]="SAJ";
area["Trinidad and Tobago"]="LATAM";
area["Tunisia"]="EMC";
area["Turkey"]="EMC";
area["Turkmenistan"]="EMC";
area["Turks and Caicos Islands"]="LATAM";
area["Tuvalu"]="SAJ";
area["Uganda"]="AME";
area["Ukraine"]="EMC";
area["United Arab Emirates"]="AME";
area["United Kingdom"]="EMC";
area["US Minor Outlying Is"]="SAJ";
area["United States Minor Outlying I"]="SAJ";
area["United States"]="NORAM";
area["Uruguay"]="LATAM";
area["Uzbekistan"]="EMC";
area["Vanuatu"]="SAJ";
area["Venezuela"]="LATAM";
area["Viet Nam"]="SAJ";
area["Virgin Islands (British)"]="LATAM";
area["Virgin Islands, British"]="LATAM";
area["Virgin Islands, U.S."]="NORAM";
area["Wallis and Futuna Islands"]="EMC";
area["Western Sahara"]="EMEA";
area["Yemen"]="AME";
area["Zambia"]="AME";
area["Zimbabwe"]="AME";
}
// Set a default region in case country list gets updated
if(typeof area[value] == 'undefined') {
// Might be called by change of topic, so value isn't a country
value = $('select[name="COLUMN17"]').val();
if(typeof area[value] == 'undefined') {
area[value] = "EMC";
}
}
if ($('input[name="COLUMN25"]').length > 0) {
$('input[name="COLUMN25"]').val(area[value]);
}
else {
$(formToValidate).append('');
}
switch(topic)
{
case "Financial Services":
case "Transport":
contactEmail="Violaine.Rigaut@gemalto.com";
break;
case "Government":
contactEmail="Eric.Billiaert@gemalto.com";
break;
case "Telecommunications":
case "Training":
case "Machine to Machine": // includes IoT
contactEmail="Marta.BORDONADA@gemalto.com";
break;
case "Website issue":
contactEmail="Laurence.Manouelides@gemalto.com";
break;
default:
contactEmail="alexander.vlasblom@gemalto.com";
}
if ($('input[name="COLUMN26"]').length > 0) {
$('input[name="COLUMN26"]').val(contactEmail);
}
else {
$(formToValidate).append('');
}
return true;
});
/**
* Define messages for different language
*/
var messages = {
en: {
required: 'The %s field is required.',
valid_email: 'The %s field must contain a valid email address.',
max_length: 'The %s field must not exceed %s characters in length.',
integer: 'The %s field must contain an integers only.',
western_character: 'You can only use western europe characters',
crm_phone: 'Format: +country number, e.g. +1 4085551212'
},
fr: {
required: 'fr: The %s field is required.',
valid_email: 'fr: The %s field must contain a valid email address.',
max_length: 'fr: The %s field must not exceed %s characters in length.',
integer: 'fr: The %s field must contain an integers only.',
western_character: 'fr: You can only use western europe characters',
crm_phone: 'Format: + , e.g. +1 4085551212'
}
};
var currentLanguage = "";
if (!currentLanguage) {
currentLanguage = "en";
}
// Set message for each rule from the current language
for (var language in messages) {
if (language === currentLanguage) {
for (var key in messages[language]) {
validator.setMessage(key, messages[language][key]);
}
}
}