function mmRangeClass() { for (var i = 0; i < arguments.length; ++i) { this[mmRangeClass.arguments[i]] = new mmRange(); } } function mmRange() { this.min = null this.height = null } var mmRanges = new mmRangeClass("Height","Weight","Weight_to_Height","Chest","Waist","Chest_Breadth","Front_Length","Back_Length","Height","Weight","Weight_to_Height","Bust","Waist","Chest_Breadth","Front_Length","Back_Length","Bust_Height","Bust_Points","Chest_to_Waist","end"); mmRanges["Height"].min = 60; mmRanges["Height"].max = 84; mmRanges["Weight"].min = 100; mmRanges["Weight"].max = 300; mmRanges["Weight_to_Height"].min = 1.6; mmRanges["Weight_to_Height"].max = 3.5; mmRanges["Chest"].min = 30; mmRanges["Chest"].max = 60; mmRanges["Waist"].min = 26; mmRanges["Waist"].max = 60; mmRanges["Chest_Breadth"].min = 7; mmRanges["Chest_Breadth"].max = 14; mmRanges["Front_Length"].min = 12; mmRanges["Front_Length"].max = 21; mmRanges["Back_Length"].min = 14; mmRanges["Back_Length"].max = 22; mmRanges["Height"].min = 60; mmRanges["Height"].max = 84; mmRanges["Weight"].min = 100; mmRanges["Weight"].max = 300; mmRanges["Weight_to_Height"].min = 1.6; mmRanges["Weight_to_Height"].max = 3.5; mmRanges["Bust"].min = 22; mmRanges["Bust"].max = 62; mmRanges["Waist"].min = 26; mmRanges["Waist"].max = 60; mmRanges["Chest_Breadth"].min = 7; mmRanges["Chest_Breadth"].max = 10; mmRanges["Front_Length"].min = 12; mmRanges["Front_Length"].max = 21; mmRanges["Back_Length"].min = 14; mmRanges["Back_Length"].max = 22; mmRanges["Bust_Height"].min = 1; mmRanges["Bust_Height"].max = 9; mmRanges["Bust_Points"].min = 1; mmRanges["Bust_Points"].max = 9; mmRanges["Chest_to_Waist"].min = 0; mmRanges["Chest_to_Waist"].max = 4.9; var reFloat = /^((\d+(\.\d*)?)|((\d*\.)?\d+))$/; var defaultEmptyOK = false //function validRange( lookup, formfield, conversionfactor, fielddesc) { // if (( (mmRanges[lookup].min * conversionfactor) > formfield.value) || ( (mmRanges[lookup].max * conversionfactor) < formfield.value)) { // alert( fielddesc + ' Out of bounds. Valid values are between ' + Math.round((mmRanges[lookup].min * conversionfactor)) + ' & ' + Math.round(( mmRanges[lookup].max * conversionfactor))); // formfield.focus(); // return false; // } // else { // return true; // } //} // trim function trim(s) { while (s.substring(0,1) == ' ') { s = s.substring(1,s.length); } while (s.substring(s.length-1,s.length) == ' ') { s = s.substring(0,s.length-1); } return s; } // Check whether string s is empty. function isEmpty(s) { return ((s == null) || (s.length == 0)) } function isEmailAddr(email) { var result = false; var theStr = new String(email); var index = theStr.indexOf("@"); if (index > 0) { var pindex = theStr.indexOf(".",index); if ((pindex > index+1) && (theStr.length > pindex+1)) result = true; } return result; } //Validate Check Box function isChecked( objFormField, strMsg) { var strValue= objFormField.checked; if ( !strValue) { alert( strMsg); objFormField.focus(); return false; } return true; } function validRequired(formField,fieldLabel) { var result = true; if (trim( formField.value) == "") { alert('Please enter a value for ' + fieldLabel +'.'); formField.focus(); result = false; } return result; } function allDigits(str) { return inValidCharSet(str,"0123456789"); } function inValidCharSet(str,charset) { var result = true; // Note: doesn't use regular expressions to avoid early Mac browser bugs for (var i=0;i 0) && (month < 13) && allDigits(elems[1]) && (day > 0) && (day < 32) && allDigits(elems[2]) && ((elems[2].length == 2) || (elems[2].length == 4)); } if (!result) { alert('Please enter a date in the format MM/DD/YYYY for the "' + fieldLabel +'" field.'); formField.focus(); } } return result; } function get_radio_value( formfield) { for (var i=0; i < formfield.length; i++) { if (formfield[i].checked) { return formfield[i].value; } } } function validStubPassword( formfield) { if ( formfield.value.length != 8) { alert( 'Password MUST be 8 characters'); formfield.focus(); return false; } } function validateOrderForm(theForm) { // Validate the order form if ( !validRequired( theForm.purchaseorder, "PO#")) { return false; } if ( !validInt( theForm.vestcount, "Estimated Vest Count for this PO", true)) { return false; } return true; } function validateSizingForm(theForm) { // we really only need to trim the measuremnts, let's make all the data look nice theForm.lastname.value = trim( theForm.lastname.value); theForm.firstname.value = trim( theForm.firstname.value); theForm.department.value = trim( theForm.department.value); theForm.m_height.value = trim( theForm.m_height.value); theForm.m_weight.value = trim( theForm.m_weight.value); theForm.m_chest.value = trim( theForm.m_chest.value); theForm.m_waist.value = trim( theForm.m_waist.value); theForm.m_chest_breadth.value = trim( theForm.m_chest_breadth.value); theForm.m_back_length.value = trim( theForm.m_back_length.value); theForm.m_front_length_standing.value = trim( theForm.m_front_length_standing.value); theForm.m_front_length_sitting.value = trim( theForm.m_front_length_sitting.value); // Validate the order form if ( !validRequired( theForm.lastname, "Last Name")) { return false; } if ( !validRequired( theForm.firstname, "First Name")) { return false; } //if ( !validRequired( theForm.department, "Division/Section")) { // return false; //} // height if ( !validRequired( theForm.m_height, "Height")) { return false; } if ( !isFloat( theForm.m_height, false)) { alert('Please enter a number for Height.'); theForm.m_height.focus(); return false; } conversionfactor = ( get_radio_value( theForm.measurements) == 'Metric') ? 2.54 : 1; // if ( !validRange( 'Height', theForm.m_height, conversionfactor, "Height")) { // return false; // } // weight if ( !validRequired( theForm.m_weight, "Weight")) { return false; } if ( !isFloat( theForm.m_weight, false)) { alert('Please enter a number for Weight.'); theForm.m_weight.focus(); return false; } conversionfactor = ( get_radio_value( theForm.measurements) == 'Metric') ? 0.45359237 : 1; // if ( !validRange( 'Weight', theForm.m_weight, conversionfactor, "Weight")) { // return false; // } // chest if ( get_radio_value( theForm.gender) == 'M') { if ( !validRequired( theForm.m_chest, "Chest")) { return false; } if ( !isFloat( theForm.m_chest, false)) { alert('Please enter a number for Chest.'); theForm.m_chest.focus(); return false; } } else { if ( !validRequired( theForm.m_bust, "Bust")) { return false; } if ( !isFloat( theForm.m_bust, false)) { alert('Please enter a number for Bust.'); theForm.m_bust.focus(); return false; } if ( !validRequired( theForm.m_under_bust, "Under Bust")) { return false; } if ( !isFloat( theForm.m_under_bust, false)) { alert('Please enter a number for Under Bust.'); theForm.m_under_bust.focus(); return false; } if ( !validRequired( theForm.m_cup_size, "Cup Size")) { return false; } } conversionfactor = ( get_radio_value( theForm.measurements) == 'Metric') ? 2.54 : 1; // if ( !validRange( 'Chest', theForm.m_chest, conversionfactor, "Chest")) { // return false; // } // waist if ( !validRequired( theForm.m_waist, "Waist")) { return false; } if ( !isFloat( theForm.m_waist, false)) { alert('Please enter a number for Waist.'); theForm.m_waist.focus(); return false; } // if ( !validRange( 'Waist', theForm.m_waist, conversionfactor, "Waist")) { // return false; // } // chest breadth if ( !validRequired( theForm.m_chest_breadth, "Chest Breadth")) { return false; } if ( !isFloat( theForm.m_chest_breadth, false)) { alert('Please enter a number for Chest Breadth.'); theForm.m_chest_breadth.focus(); return false; } // if ( !validRange( 'Chest_Breadth', theForm.m_chest_breadth, conversionfactor, "Chest Breadth")) { // return false; // } // back length if ( !validRequired( theForm.m_back_length, "Back Length")) { return false; } if ( !isFloat( theForm.m_back_length, false)) { alert('Please enter a number for Back Length.'); theForm.m_back_length.focus(); return false; } // if ( !validRange( 'Back_Length', theForm.m_back_length, conversionfactor, "Back Length")) { // return false; // } // front length standing if ( !validRequired( theForm.m_front_length_standing, "Front Length Standing")) { return false; } if ( !isFloat( theForm.m_front_length_standing, false)) { alert('Please enter a number for Front Length Standing.'); theForm.m_front_length_standing.focus(); return false; } // if ( !validRange( 'Front_Length', theForm.m_front_length_standing, conversionfactor, "Front Length Standing")) { // return false; // } // front length sitting if ( !validRequired( theForm.m_front_length_sitting, "Front Length Sitting")) { return false; } if ( !isFloat( theForm.m_front_length_sitting, false)) { alert('Please enter a number for Front Length Sitting.'); theForm.m_front_length_sitting.focus(); return false; } // if ( !validRange( 'Front_Length', theForm.m_front_length_sitting, conversionfactor, "Front Length Sitting")) { // return false; // } return true; } function validateRegisterUser(theForm) { if ( !validRequired(theForm.textfield_firstname,'First Name')) { theForm.textfield_firstname.focus(); theForm.textfield_firstname.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_lastname,'Last Name')) { theForm.textfield_lastname.focus(); theForm.textfield_lastname.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_company,'Company')) { theForm.textfield_company.focus(); theForm.textfield_company.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_address1,'Address')) { theForm.textfield_address1.focus(); theForm.textfield_address1.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_city,'City')) { theForm.textfield_city.focus(); theForm.textfield_city.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_zip,'Postal/Zip')) { theForm.textfield_zip.focus(); theForm.textfield_zip.className = 'form_error'; return false; } if ( !validRequired(theForm.textfield_phone,'Phone')) { theForm.textfield_phone.focus(); theForm.textfield_phone.className = 'form_error'; return false; } // Email validations if ( !validRequired(theForm.textfield_email,'Email')) { theForm.textfield_email.focus(); theForm.textfield_email.className = 'form_error'; return false; } if ( !isEmailAddr( theForm.textfield_email.value)) { alert( 'Email address entered is not valid.'); theForm.textfield_email.focus(); return false; } if ( theForm.textfield_email.value != theForm.textfield_confirmemail.value) { alert( "Email and Confirm Email must match."); theForm.textfield_email.focus(); theForm.textfield_email.className = 'form_error'; return false; } return true; }