[REBOL] Re: HTTP-Post Error
From: mattymattkim:h:otmail at: 29-Oct-2002 10:28
The site uses a lot of flash, could this pose a problem?
Here's the source code for the form:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
<link rel="stylesheet" href="/ssi/english/vehicles/saab/stylesheet.css"
type="text/css">
<script src="/ssi/english/vehicles/js/saabLMP_pulldown.js"
language="JavaScript"></script>
<script language="javascript">
<!--
var LMPCookie = document.cookie;
function getCookie(cookieName) {
var index = LMPCookie.indexOf(cookieName +"=");
if (index == -1) return null
index = LMPCookie.indexOf("=", index) + 1;
var endIndex = LMPCookie.indexOf(";", index);
if (endIndex == -1) endIndex = LMPCookie.length;
return unescape(LMPCookie.substring(index, endIndex));
}
var cookieVal = getCookie("saab_lmp_rules");
if (cookieVal == 999) location.href /ssi/english/vehicles/saab/lmp/rules.html
;
function makeLeadingZero(str) {
if (str.length == 1) {
str = "0" + str;
}
return str;
}
function setCreateDate() {
var theDate = new Date();
var theYear = theDate.getFullYear().toString();
var theMonth = (theDate.getMonth() + 1).toString();
theMonth = makeLeadingZero(theMonth);
var theDay = theDate.getDate().toString();
theDay = makeLeadingZero(theDay);
document.forms[0].create_date.value = theYear + theMonth + theDay;
}
function populateIDs() {
var queryString = top.queryString;
if ((queryString.indexOf("surveyID=")) == -1) {
//traditional querystring has not carried, fall back to get value from
cookie
var strCookie = document.cookie
var strVUE = "VUE_LMP_ids="
queryString = strCookie.substring(strCookie.indexOf(strVUE) +
strVUE.length, strCookie.indexOf(";"));
}
var surveyStr = "surveyID=";
var surveyStart = queryString.indexOf(surveyStr) + surveyStr.length;
if (queryString.indexOf(surveyStr) != -1) {
//if survey ID submitted to form, find length of survey ID number
var endIndex = queryString.indexOf("&", surveyStart);
if (endIndex != -1) {
//querystring continues after survey ID, therefore ends at &
var surveyLen = endIndex - surveyStart;
} else {
//querystring ends with survey ID
var surveyLen = queryString.length - surveyStart;
}
//write ID to hidden form field
var surveyID = queryString.substr(surveyStart, surveyLen);
//document.forms[0].component_code.value = surveyID;
}
var eventStr = "eventCode=";
var eventStart = queryString.indexOf(eventStr) + eventStr.length;
if (queryString.indexOf(eventStr) != -1) {
var endIndex = queryString.indexOf("&", eventStart);
if (endIndex != -1) {
var eventLen = endIndex - eventStart;
} else {
var eventLen = queryString.length - eventStart;
}
//write ID to hidden form field
var eventCode = queryString.substr(eventStart, eventLen);
document.forms[0].event_code.value = eventCode;
}
//alert(surveyID +", "+ eventCode);
}
function prefillSelections() {
writeNewList(document.forms[0].cv_namplt_desc_1, arrNameplate);
writeNewList(document.forms[0].cv_namplt_desc_2, arrNameplate);
writeNewList(document.forms[0].ft_namplt_desc_1, arrNameplate);
writeNewList(document.forms[0].ft_namplt_desc_2, arrNameplate);
return true;
}
var missingRequiredFieldError = "Please complete the {FIELD_NAME} field.";
var emailAddressError = "You have entered an incorrect or invalid email
address.";
var postalCodeError = "You have entered an incorrect or invalid postal
code.";
var numericError = "You have entered an incorrect or invalid
{FIELD_NAME}.";
var leaseEndDateError = "You have entered an invalid date for
{FIELD_NAME}.";
var languageSelectError = "You must choose a language.";
var replaceFieldName = /{FIELD_NAME}/gi
function validateForm(theForm)
{
valid = true;
stripSpecialCharactersFromField(theForm.first_name_and_initial);
stripSpecialCharactersFromField(theForm.last_name);
stripSpecialCharactersFromField(theForm.address_line_1);
stripSpecialCharactersFromField(theForm.address_line_2);
stripSpecialCharactersFromField(theForm.city_name);
stripPunctuationFromField(theForm.first_name_and_initial);
stripPunctuationFromField(theForm.last_name);
stripPunctuationFromField(theForm.address_line_1);
stripPunctuationFromField(theForm.address_line_2);
stripPunctuationFromField(theForm.city_name);
if (valid && (theForm.first_name_and_initial.value == ""))
{ valid = false;
theForm.first_name_and_initial.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
First Name
);
alert(errMsg);
}
if (valid && (theForm.last_name.value == ""))
{ valid = false;
theForm.last_name.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
Last Name
);
alert(errMsg);
}
if (valid && (theForm.address_line_1.value == ""))
{ valid = false;
theForm.address_line_1.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
Address
);
alert(errMsg);
}
if (valid && (theForm.city_name.value == ""))
{ valid = false;
theForm.city_name.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
City
);
alert(errMsg);
}
if (valid && (theForm.candn_provnc_or_trtry_cd.selectedIndex == ""))
{ valid = false;
theForm.candn_provnc_or_trtry_cd.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
Province
);
alert(errMsg);
}
var pcode = theForm.candn_forwrd_sortn_code.value +
theForm.candn_local_dstrbn_unit_cd.value;
if (valid && pcode != "")
{ valid = valid && validatePostalCode(pcode);
if (!valid)
{ theForm.candn_forwrd_sortn_code.focus();
alert(postalCodeError);
}
}
if (valid && ((theForm.hom_ph_area_code.value == "") ||
(theForm.hom_ph_phone_nbr.value == "")))
{ valid = false;
theForm.hom_ph_area_code.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
Home Phone Number
);
alert(errMsg);
}
stripPunctuationFromField(theForm.hom_ph_area_code);
stripPunctuationFromField(theForm.hom_ph_phone_nbr);
if (valid && ((theForm.hom_ph_area_code.value != "") ||
(theForm.hom_ph_phone_nbr.value != "")))
{
if ((theForm.hom_ph_area_code.value.length == 3) &&
(theForm.hom_ph_phone_nbr.value.length == 7))
{
valid = valid &&
validateNumericValue(theForm.hom_ph_area_code, "Home phone area code",
true);
valid = valid &&
validateNumericValue(theForm.hom_ph_phone_nbr, "Home phone number", true);
}else
{ valid = false;
theForm.hom_ph_area_code.focus();
var errMsg = numericError.replace(replaceFieldName, "home
phone number");
alert(errMsg);
}
}
if (valid && ((theForm.bus_ph_area_code.value == "") ||
(theForm.bus_ph_phone_nbr.value == "")))
{ valid = false;
theForm.bus_ph_area_code.focus();
var errMsg = missingRequiredFieldError.replace(replaceFieldName,
business phone number
);
alert(errMsg);
}
stripPunctuationFromField(theForm.bus_ph_area_code);
stripPunctuationFromField(theForm.bus_ph_phone_nbr);
if (valid && ((theForm.bus_ph_area_code.value != "") ||
(theForm.bus_ph_phone_nbr.value != "")))
{
if ((theForm.bus_ph_area_code.value.length == 3) &&
(theForm.bus_ph_phone_nbr.value.length == 7))
{
valid = valid &&
validateNumericValue(theForm.bus_ph_area_code, "Business phone area code",
true);
valid = valid &&
validateNumericValue(theForm.bus_ph_phone_nbr, "Business phone number",
true);
}else
{ valid = false;
theForm.bus_ph_area_code.focus();
var errMsg = numericError.replace(replaceFieldName, "business
phone number");
alert(errMsg);
}
}
/*
if (valid && ((theForm.purchs_int_rng_cd[0].checked == false) &&
(theForm.purchs_int_rng_cd[1].checked == false) &&
(theForm.purchs_int_rng_cd[2].checked == false) &&
(theForm.purchs_int_rng_cd[3].checked == false) &&
(theForm.purchs_int_rng_cd[4].checked == false) &&
(theForm.purchs_int_rng_cd[5].checked == false)))
{ valid = false;
theForm.purchs_int_rng_cd[0].focus();
var errMsg = "Please tell us when you expect to obtain your next
vehicle.";
alert(errMsg);
}
if (valid && ((theForm.acqstn_methd_cd[0].checked == false) &&
(theForm.acqstn_methd_cd[1].checked == false)))
{ valid = false;
theForm.acqstn_methd_cd[0].focus();
var errMsg = "Please tell us how you expect to obtain your next
vehicle.";
alert(errMsg);
}
*/
//alert(document.forms[0].CURRENT_VEHICLE_MANUFACTURER_1.value);
return valid;
}
function stripPunctuationFromField(fieldObject)
{
fieldObject.value = stripPunctuation(fieldObject.value);
}
function stripPunctuation(theValue)
{
var returnMe = "";
var validChars = "0123456789 ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for (i=0; i<theValue.length; i++)
{ var theChar = theValue.substring(i, i+1);
if (validChars.indexOf(theChar.toUpperCase()) > -1)
{ returnMe += theChar;
}
}
return returnMe;
}
function stripSpecialCharactersFromField(fieldObject)
{
fieldObject.value = stripSpecialCharacters(fieldObject.value);
}
function stripSpecialCharacters(theValue)
{
var returnMe = "";
var numSpecialChars = 8;
var validChars = ["A", "C", "E", "I", "N", "O", "U", "Y"];
var special_a = ["À", "Á", "Â", "Ã", "Ä"];
var special_c = ["Ç"];
var special_e = ["È", "É", "Ê", "Ë"];
var special_i = ["Ì", "Í", "Î", "Ï"];
var special_n = ["Ñ"];
var special_o = ["Ò", "Ó", "Ô", "Õ", "Ö"];
var special_u = ["Ù", "Ú", "Û", "Ü"];
var special_y = ["Ý"];
var specialChars = [special_a, special_c, special_e, special_i, special_n,
special_o, special_u, special_y];
for (x = 0; x < theValue.length; x++)
{ var theChar = theValue.substring(x, x+1);
for (i = 0; i < numSpecialChars; i++)
{ for (j = 0; j < specialChars[i].length; j++)
{ if (theChar.toUpperCase() == specialChars[i][j])
{ theChar = validChars[i]
}
}
}
returnMe += theChar
}
return returnMe;
}
/**
* Checks that all chars in theValue are digits.
*/
function allCharsAreDigits(theValue)
{
for (var i=0; i<theValue.length; i++)
{ var theDigit = theValue.substring(i, (i+1));
if (!(parseInt(theDigit) > -1))
{ return false;
}
}
return true;
}
function validateNumericValue(fieldObject, fieldName, showErrorMsg)
{
var valid = allCharsAreDigits(fieldObject.value);
if (!valid && showErrorMsg)
{ fieldObject.focus();
var errMsg = numericError.replace(replaceFieldName, fieldName);
alert(errMsg);
}
return valid;
}
function validateEmailAddress(theValue)
{
var valid = true;
var a = theValue.indexOf("@");
if ((a < 1) || (a == (theValue.length - 1)))
{ valid = false;
}else
{
var emailName = theValue.substring(0, a);
var emailDomain = theValue.substring(a+1);
valid = valid && validateEmailName(emailName);
valid = valid && validateEmailDomain(emailDomain);
}
return valid;
}
function validateEmailDomain(theDomain)
{
var dot = theDomain.indexOf(".");
if ((dot < 1) || (dot == (theDomain.length -1)))
{ return false;
}
return validateEmailName(theDomain);
}
/**
* Returns true if theAddress is a valid email name, else returns false.
* The name is the bit before the @.
*/
function validateEmailName(theName)
{
if ((theName.length < 1) || (theName.length > 25))
{ return false;
}
var encoded = escape(theName);
if ((encoded.indexOf("%") < 0) &&
(encoded.indexOf("*") < 0) &&
(encoded.indexOf("+") < 0) &&
(encoded.indexOf("/") < 0) &&
(encoded.indexOf("@") < 0))
{ return true;
}else
{ return false;
}
}
/**
* Checks that the postal code is in a valid format.
* Param is a form text object.
*/
function validatePostalCode(formObject)
{
var valid = true;
var userPostalCode = formObject.value;
// Strip spaces:
var s = userPostalCode.indexOf(" ");
while (s > -1)
{ userPostalCode = userPostalCode.substring(0, s) +
userPostalCode.substring(s+1);
s = userPostalCode.indexOf(" ");
}
formObject.value = userPostalCode.toUpperCase();
// Check the length of the postal code:
if (userPostalCode.length != 6)
{ valid = false;
}else
{
var letter1 = userPostalCode.substring(0,1).toUpperCase();
var letter2 = userPostalCode.substring(1,2).toUpperCase();
var letter3 = userPostalCode.substring(2,3).toUpperCase();
var letter4 = userPostalCode.substring(3,4).toUpperCase();
var letter5 = userPostalCode.substring(4,5).toUpperCase();
var letter6 = userPostalCode.substring(5,6).toUpperCase();
var validLetters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var validDigits = "0123456789";
// Check that the chars are valid values:
if ((validLetters.indexOf(letter1) > -1) &&
(validDigits.indexOf(letter2) > -1) &&
(validLetters.indexOf(letter3) > -1) &&
(validDigits.indexOf(letter4) > -1) &&
(validLetters.indexOf(letter5) > -1) &&
(validDigits.indexOf(letter6) > -1))
{ // OK
valid = valid && true;
}else
{ valid = false;
}
}
return valid;
}
function validateLeaseEndDate(theForm, whichLease)
{
var valid = true;
var leaseDate = "";
if ((eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease +
'_YYYY.value != ""')) ||
(eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease +
'_MM.value != ""')) ||
(eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease +
'_DD.value != ""')))
{
valid = valid &&
validateDate(eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease +
'_DD'), eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease +
_MM
), eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease +
_YYYY
));
if (valid)
{ leaseDate = "" +
eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_YYYY.value")
+
eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_MM.value") +
eval("theForm.CURRENT_VEHICLE_LEASE_END_DATE_" + whichLease + "_DD.value");
}
}
eval('theForm.CURRENT_VEHICLE_LEASE_END_DATE_' + whichLease + '.value
= leaseDate');
return valid;
}
/**
* Checks the three supplied form objects to see if they are valid
numbers.
* Adds a '0' to the beginning of single-digit day and month fields.
* Puts the altered values into the form objects.
*/
function validateDate(dayFormObject, monthFormObject, yearFormObject)
{
var day = dayFormObject.value;
var month = monthFormObject.value;
var year = yearFormObject.value;
if ((day.length > 2) || (month.length > 2) || (year.length != 4))
{ return false;
}
if ((navigator.appVersion.substring(0,3) >= "3.0" &&
navigator.appName == "Netscape") ||
(navigator.appVersion.substring(0,3) >= "4.0" &&
navigator.appName.substring(0,9) == "Microsoft"))
{
i