/** * Form error strings * Multi-dimentional array, in the format: * * element_name : this is the name of the SPAN element where the error message appears * |_ error_type * |_ short_message * |_ long_message */ var form_error_strings = { 'email': { 'empty': { 'short': 'Required field', 'long': 'Email field in the "Account Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Email field in the "Account Details" part contain illegal email address.' } }, 'password': { 'empty': { 'short': 'Required field', 'long': 'Password field in the "Account Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Password field in the "Account Details" part, should be 4-20 digits and/or characters.' } }, 'password_confirm': { 'invalid': { 'short': 'Passwords do not match', 'long': 'Password confirm field in the "Account Details" part do not match the password field.' } }, 'bill_first_name': { 'empty': { 'short': 'Required field', 'long': 'First name field in the "Billing Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'First name field in the "Billing Details" part contain illegal character/s.' } }, 'bill_last_name': { 'empty': { 'short': 'Required field', 'long': 'Last name field in the "Billing Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Last name field in the "Billing Details" part contain illegal character/s.' } }, 'bill_address': { 'empty': { 'short': 'Required field', 'long': 'Street address field in the "Billing Details" part is required.' }, 'invalid1': { 'short': 'Invalid input', 'long': 'Street address field in the "Billing Details" part contain illegal character/s.' }, 'invalid2': { 'short': 'Invalid input', 'long': 'Street name in "Billing Details" is required' } }, 'bill_city': { 'empty': { 'short': 'Required field', 'long': 'City field in the "Billing Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'City field in the "Billing Details" part contain illegal character/s.' } }, 'bill_zip_code': { 'empty': { 'short': 'Required field', 'long': 'Zip code field in the "Billing Details" part is required.' }, 'invalid1': { 'short': 'Invalid input', 'long': 'Zip code field in the "Billing Details" part should contain your 5-digit zip code and not your state abbreviation.' }, 'invalid2': { 'short': 'Invalid input', 'long': 'Zip code field in the "Billing Details" part contain illegal character/s.' } }, 'bill_country': { 'empty': { 'short': 'Required field', 'long': 'Country field in the "Billing Details" part is required.' } }, 'bill_state_canada': { 'empty': { 'short': 'Required field', 'long': 'State field in the "Billing Details" part is required.' } }, 'bill_state_us': { 'empty': { 'short': 'Required field', 'long': 'State field in the "Billing Details" part is required.' } }, 'bill_phone': { 'empty1': { 'short': 'Country code required', 'long': 'Phone country code field in the "Billing Details" part is required.' }, 'invalid1': { 'short': 'Invalid input', 'long': 'Phone country code field in the "Billing Details" can only include numbers.' }, 'empty2': { 'short': 'Area code required', 'long': 'Phone area code field in the "Billing Details" part is required.' }, 'invalid2': { 'short': 'Invalid input', 'long': 'Phone area code field in the "Billing Details" can only include numbers.' }, 'empty3': { 'short': 'Phone number required', 'long': 'Phone number field in the "Billing Details" part is required.' }, 'invalid3': { 'short': 'Invalid input', 'long': 'Phone number field in the "Billing Details" can only include numbers.' } }, 'ship_first_name': { 'empty': { 'short': 'Required field', 'long': 'First name field in the "Shipping Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'First name field in the "Shipping Details" part contain illegal character/s.' } }, 'ship_last_name': { 'empty': { 'short': 'Required field', 'long': 'Last name field in the "Shipping Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Last name field in the "Shipping Details" part contain illegal character/s.' } }, 'ship_address': { 'empty': { 'short': 'Required field', 'long': 'Street address field in the "Shipping Details" part is required.' }, 'invalid1': { 'short': 'Invalid input', 'long': 'Street address field in the "Shipping Details" part contain illegal character/s.' }, 'invalid2': { 'short': 'Invalid input', 'long': 'Street name in "Shipping Details" is required' } }, 'ship_city': { 'empty': { 'short': 'Required field', 'long': 'City field in the "Shipping Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'City field in the "Shipping Details" part contain illegal character/s.' } }, 'ship_zip_code': { 'empty': { 'short': 'Required field', 'long': 'Zip code field in the "Shipping Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Zip code field in the "Shipping Details" part contain illegal character/s.' } }, 'ship_country': { 'empty': { 'short': 'Required field', 'long': 'Country field in the "Shipping Details" part is required.' } }, 'ship_state_canada': { 'empty': { 'short': 'Required field', 'long': 'State field in the "Shipping Details" part is required.' } }, 'ship_state_us': { 'empty': { 'short': 'Required field', 'long': 'State field in the "Shipping Details" part is required.' } }, 'ship_phone': { 'empty1': { 'short': 'Country code required', 'long': 'Phone country code field in the "Shipping Details" part is required.' }, 'invalid1': { 'short': 'Invalid input', 'long': 'Phone country code field in the "Shipping Details" can only include numbers.' }, 'empty2': { 'short': 'Area code required', 'long': 'Phone area code field in the "Shipping Details" part is required.' }, 'invalid2': { 'short': 'Invalid input', 'long': 'Phone area code field in the "Shipping Details" can only include numbers.' }, 'empty3': { 'short': 'Phone number required', 'long': 'Phone number field in the "Shipping Details" part is required.' }, 'invalid3': { 'short': 'Invalid input', 'long': 'Phone number field in the "Shipping Details" can only include numbers.' } }, 'pay_full_name': { 'empty': { 'short': 'Required field', 'long': 'Cardholder name field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Cardholder name field in the "Payment Details" part contain illegal character/s.' } }, 'pay_cc_card_number': { 'empty': { 'short': 'Required field', 'long': 'Credit card number field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Credit card number field in the "Payment Details" can contain only numbers.' }, 'invalidmastercard1': { 'short': 'Invalid input', 'long': 'Credit card number field in the "Payment Details" part contains non-valid MasterCard number.' }, 'invalidmastercard2': { 'short': 'Invalid input', 'long': 'Sorry, temporarily we are not processing MasterCard. Please try again using a Visa-, American Express-, Diners- or JCB Credit Card. We also accept E-check payments.' }, 'invalidvisa': { 'short': 'Invalid input', 'long': 'Credit card number field in the "Payment Details" part contain not valid Visa number.' }, 'invaliddiners': { 'short': 'Invalid input', 'long': 'Sorry, temporarily we are not processing Diners, please switch to VISA or E-check' }, 'invalidamex': { 'short': 'Invalid input', 'long': 'Sorry, temporarily we are not processing American Express, please switch to VISA or E-check.' } }, 'pay_cc_exp': { 'empty1': { 'short': 'Month required', 'long': 'Expiration month field in the "Payment Details" part is required.' }, 'empty2': { 'short': 'Year required', 'long': 'Expiration year field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Exp. date in the past', 'long': 'Expiration date in the "Payment Details" part must be in future.' } }, 'pay_cc_cvv': { 'empty': { 'short': 'Required field', 'long': 'CVV Code field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'CVV Code field in the "Payment Details" part contain illegal character/s. must contain 3 digits' } }, 'turing_key': { 'empty': { 'short': 'Required field', 'long': 'Confirm code field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Confirm code field in the "Payment Details" section contains illegal characters, it must contain 5 characters from the image above the field.' } }, 'pay_echeck_routing_number': { 'empty': { 'short': 'Required field', 'long': 'Routing number field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Routing number field in the "Payment Details" part contain illegal character/s. must contain only digits' } }, 'pay_echeck_account_number': { 'empty': { 'short': 'Required field', 'long': 'Account number field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Account number field in the "Payment Details" part contain illegal character/s. must contain only digits' } }, 'pay_echeck_bank_name': { 'empty': { 'short': 'Required field', 'long': 'Bank Name field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Bank name field in the "Payment Details" part contain illegal character/s.' } }, 'echeck_bank_state_canada': { 'empty': { 'short': 'Required field', 'long': 'Bank state field in the "Payment Details" part is required.' } }, 'echeck_bank_state_us': { 'empty': { 'short': 'Required field', 'long': 'Bank state field in the "Payment Details" part is required.' } }, 'pay_pp_email': { 'empty': { 'short': 'Required field', 'long': 'Email field in the "Payment Details" part is required.' }, 'invalid': { 'short': 'Invalid input', 'long': 'Email field in the "Payment Details" part contain illegal email address.' } }, 'pay_elv_account_holder': { 'empty': { 'short': 'Required field', 'long': 'Account Holder Name field in the "Payment Details" part is required.' } }, 'pay_elv_account_number': { 'empty': { 'short': 'Required field', 'long': 'Account number field in the "Payment Details" part is required.' } }, 'pay_elv_routing_number': { 'empty': { 'short': 'Required field', 'long': 'Bank Code field in the "Payment Details" part is required.' } }, 'pay_elv_bankcode': { 'empty': { 'short': 'Required field', 'long': 'Bank Code field in the "Payment Details" part is required.' } }, 'pay_elv_bankname': { 'empty': { 'short': 'Required field', 'long': 'Bank Name field in the "Payment Details" part is required.' } }, 'pay_elv_id_card': { 'invalid1': { 'short': 'Part I invalid', 'long': 'ID card part I contains invalid information' }, 'invalid2': { 'short': 'Part II invalid', 'long': 'ID card part II contains invalid information' }, 'invalid3': { 'short': 'Part III invalid', 'long': 'ID card part III contains invalid information' }, 'invalid4': { 'short': 'Part IV invalid', 'long': 'ID card part IV contains invalid information' } }, 'statement_confirm': { 'invalid': { 'short': 'Please confirm', 'long': 'Please Certify the Terms of Use statement.' } }, 'payment_confirm': { 'invalid': { 'short': 'Please confirm', 'long': 'Please check the box confirming that you read and confirmed your order details.' } } } /** * Retrieve the appropriate error string. * @param {string} element ID * @param {string} error type * @param {bool} long_msg */ function get_form_error_string(element, type, long_msg) { var msg; if (element != '') { element = form_error_resolve_span_name(element); if (element) { if (type != '' && form_error_strings[element]) { if (typeof(long_msg) == 'boolean' && form_error_strings[element][type]) { msg = form_error_strings[element][type][(long_msg?'long':'short')]; return msg || false; } msg = form_error_strings[element][type]; return msg || false; } msg = form_error_strings[element]; return msg || false; } return false; } return false; } /** * Since we have a few elements that show their error in the same span, * we need to find the correct span element for the input elements. * @param {string} element_name */ function form_error_resolve_span_name(element_name) { if (typeof(element_name) != 'string') { return false; } var element_name_excep = ['pay_cc_exp','bill_country','bill_phone','ship_phone','pay_elv_id_card']; for (var i in element_name_excep) { if (element_name.indexOf(element_name_excep[i]) != -1) { return element_name_excep[i]; } } return element_name; }