// This is a JavaScript file. Edit it only if you need extra forms in the registration sequence function isLoaded() { return 'yes'; } // For construction new form objects function forms(frmValue) { this.frmValue = frmValue; return this; } // The array of forms. This array contains all the forms that are to be shown // during the form sequence in the registration. Add extra forms here. var rgUnit = new Array( new forms(''), new forms(''), new forms('') ); function elementFrmObj(name, type, value, selectedIndex) { this.name = name; this.type = type; this.value = value; this.selectedIndex = selectedIndex; } var unitCounter = 0; // initialized the variable.. var frmNumber = 0; // initialze to zero the number of forms.. var frmElementArray; var frmElements; var currentFrm = ''; var errFlag = false; // initialize to false var errMsg = ''; // initialize to empty string var frmFrame = parent.frames[2]; var navFrame = parent.frames[3]; var units; function trimString(stringobj) { // parse the element value...to remove leading/trailing spaces.. RegExp.multiline = true; myRegExpLead = /^\s*/; stringobj.value = stringobj.value.replace(myRegExpLead, ''); myRegExpTail = /\s*$/; stringobj.value = stringobj.value.replace(myRegExpTail, ''); stringobj.value = escape(stringobj.value); RegExp.multiline = false; } function verifyInput() { // we go through all the form elements and verify whether they are valid... frmElements = frmFrame.document.forms[0].elements; for (elementCntr=0;elementCntr<=frmElements.length-1;elementCntr++) { if (errFlag) { return errFlag; } else { frmElements[elementCntr].value = unescape(frmElements[elementCntr].value); switch (frmElements[elementCntr].name) { case 'anbTitle' : if (frmElements[elementCntr].selectedIndex == 0) { errMsg = 'Please choose a Title - note that fields with an asterisk mark are mandatory'; errFlag = true; } break; case 'anbFName' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter a First Name - note that fields with an asterik mark are mandatory'; errFlag = true; } break; case 'anbLName' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter a Last Name - note that fields with an asterik mark are mandatory'; errFlag = true; } break; case 'anbAddress' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter the address - note that fields with an asterik mark are mandatory'; errFlag = true; } break; case 'anbCntry' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please choose a Country - note that fields with an asterik mark are mandatory'; errFlag = true; } break; case 'anbEmail' : if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter a valid email address - note that fields with an asterik mark are mandatory'; errFlag = true; } else { myRegExp = /^\w+([\.\-]{0,1}\w)*\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/ results = frmElements[elementCntr].value.match(myRegExp); if (results == null) { errMsg = 'Please enter a valid email address'; errFlag = true; } } break; case 'anbPhone' : trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter a phone number - note that fields with an asterik mark are mandatory'; errFlag = true; } break; case 'rgsTagName' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter a name for your tag - note that fields with an asterisk mark are mandatory'; errFlag = true; } break; case 'rgsTagAddress' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'Please enter an institution for your tag - note that fields with an asterisk mark are mandatory'; errFlag = true; } break; case 'pymMethod' : if ((frmElements[elementCntr].selectedIndex < 0) || (frmElements[elementCntr].selectedIndex > 2)) { errMsg = 'Please choose a method of payment - note that fields with an asterik mark are mandatory'; errFlag = true; } else { optionIndex = frmElements[elementCntr].selectedIndex; paymentMethod = frmElements[elementCntr].options[optionIndex].value; } break; case 'pymCardType' : if (paymentMethod == 'crd') { if (frmElements[elementCntr].selectedIndex == 0) { errMsg = 'You have selected credit card as mode of payment - please choose a valid card type'; errFlag = true; } } break; case 'pymCardHolderName' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if (paymentMethod == 'crd') { if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'You have selected credit card as mode of payment - please choose name of the card holder'; errFlag = true; } } break; case 'pymCardNumber' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if (paymentMethod == 'crd') { if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'You have selected credit card as mode of payment - please enter the card number'; errFlag = true; } } break; case 'pymCardDate' : // parse the element value...to remove leading/trailing spaces.. trimString(frmElements[elementCntr]); if (paymentMethod == 'crd') { if ((frmElements[elementCntr].value == null) || (frmElements[elementCntr].value == '') || (frmElements[elementCntr].value == 'none')) { errMsg = 'You have selected credit card as mode of payment - please enter the expiry date of the card'; errFlag = true; } } break; } } } return errFlag; } function storeFrmDet() { // store the form element values of each form..in an array.. var tempFrmObj = new Array(); elementCntr = 0; optionIndex = 0; for (elementCntr=0;elementCntr<=frmElements.length-1;elementCntr++) { if ((frmElements[elementCntr].type == "select-one") || (frmElements[elementCntr].type == "select-multiple")) { optionIndex = frmElements[elementCntr].selectedIndex; tempFrmObj[elementCntr] = new elementFrmObj(frmElements[elementCntr].name,frmElements[elementCntr].type,frmElements[elementCntr].options[optionIndex].value,frmElements[elementCntr].selectedIndex); } else { if ((frmElements[elementCntr].value == "") || (frmElements[elementCntr].value == null)) { frmElements[elementCntr].value = "none"; } tempFrmObj[elementCntr] = new elementFrmObj(frmElements[elementCntr].name,frmElements[elementCntr].type,frmElements[elementCntr].value,0); } } frmElementArray[unitCounter] = tempFrmObj; } function restoreFrmDet() { if (frmElementArray[unitCounter] != null) { var strFrmElements = new Array(); var curFrmElements = new Array(); elementCntr = 0; strFrmElements = frmElementArray[unitCounter]; curFrmElements = frmFrame.document.forms[0].elements; for (elementCntr=0;elementCntr<=curFrmElements.length-1;elementCntr++) { if ((curFrmElements[elementCntr].type == "select-one") || (curFrmElements[elementCntr].type == "select-multiple")) { curFrmElements[elementCntr].selectedIndex = strFrmElements[elementCntr].selectedIndex; } else { curFrmElements[elementCntr].value = unescape(strFrmElements[elementCntr].value); } } } } // create a parser to check code.................................................................... function parseDocument(mode,currentFrm,frmString) { var results = ''; var myRegExp = ''; if (mode == 'nLine') { myRegExp = /^\s*([.\n]*)\s*\n*$/; results = frmString.match(myRegExp); if (results != null) { frmString = frmString.replace(myRegExp, '$1'); } return frmString; } if (mode == 'jsSub') { // replace a comanchejs form variable.. myRegExp = /\<\!\-\-\s*COMANCHEJS\:FRMDETAILS\s*\-\-\>/; results = currentFrm.match(myRegExp); if (results != null) { currentFrm = currentFrm.replace(myRegExp, frmString); } return currentFrm; } if (mode == 'errSub') { // replace a comanchejs error variable myRegExp = /\<\!\-\-\s*COMANCHEJS\:ERRDETAILS\s*\-\-\>/; results = currentFrm.match(myRegExp); if (results != null) { currentFrm = currentFrm.replace(myRegExp, frmString); } return currentFrm; } } function updateFrm() { var tempUnitCntr = 0; var tmpFrmObject = new Array(); var frmString = ''; for (tmpUnitCntr=0;tmpUnitCntr '; } } // now load the other form..and then replace..stuff.. currentFrm = units[unitCounter].frmValue; currentFrm = parseDocument('jsSub',currentFrm,frmString); // parse the html form to replace tag values of type COMANCHEJS // load the final form.. frmFrame.location.replace("javascript: parent.frames[3].currentFrm"); } function resetFrm() { frmFrame.document.forms[0].reset(); } function nextFrm() { if (!verifyInput()) { if (unitCounter < frmNumber-1) { storeFrmDet(); // store current frm details..b4 we move ahead.. unitCounter++; if (unitCounter == frmNumber-1) { // I have to actually spit out all the form elements...into this form..before it goes out.. updateFrm(); } else { loadFrm(); } setTimeout('restoreFrmDet()',200); // restore the details if available; } } else { alert(errMsg); errFlag = false; errMsg = ''; } } function previousFrm() { if (unitCounter > 0) { frmElements = frmFrame.document.forms[0].elements; storeFrmDet(); // store the frm details.. overwrite if necessary unitCounter--; loadFrm(); setTimeout('restoreFrmDet()',200); // restore the details if available; } } function loadFrm() { currentFrm = units[unitCounter].frmValue; frmFrame.location.replace("javascript: parent.frames[3].currentFrm"); } function submitDet() { if (!verifyInput()) { // quickly unescape the lot, then submit to server frmElements = frmFrame.document.forms[0].elements; for (elementCntr=0;elementCntr<=frmElements.length-1;elementCntr++) { frmElements[elementCntr].value = unescape(frmElements[elementCntr].value); } frmFrame.document.forms[0].submit(); } else { alert(errMsg); errFlag = false; errMsg = ''; } } function init(unitName) { switch(unitName) { case 'rg' : units = new Array(); // some initialization units = rgUnit; // set units array equal to the rgUnit unitCounter = 0; // re-initialize the counter frmNumber = units.length; // get number of forms.. frmElementArray = new Array(); loadFrm(); // open up the first form... } }