Require at LEAST ONE checkbox in a long list, using formmail

  • plumloopy
  • Newbie
  • Newbie
  • plumloopy
  • Posts: 5

Post 3+ Months Ago

First of all, I've examined http://www.ozzu.com/programming-forum/perl-help-validating-more-than-one-field-t25433.html which deals with this somewhat, but I haven't had luck yet. Possibly this solution will work for me but I've had trouble thus far. I'm open to using Java but this particular page currently has none.

Here is my code:

<font size="-1">CHOOSE FROM CURRENT AND FORTHCOMING TITLES:</font>
</font></font></b></td></tr>
<tr><td valign="top" width="44" bgcolor="#000090" bordercolor="#FFFFFF">
<input type="checkbox" name="al3" value="al3"><br>
<b><font face="Arial, Helvetica"><font color="#ffffff">
<font size="-1">&nbsp;Order</font></font></font></b></td>
<td width="357"><b><font face="Arial, Helvetica"><font size="-1">
<a href="active3.html">THE ACTIVE LEARNER: SUCCESSFUL STUDY STRATEGIES, 3rd ed.</a>
</font></font></b></td></tr>
<tr><td valign="top" width="44" bgcolor="#000090" bordercolor="#FFFFFF">
<input type="checkbox" name="dcj2" value="dcj2"><br>
<b><font face="Arial, Helvetica"><font color="#ffffff">
<font size="-1">Order</font></font></font></b></td>
<td width="357"><b><font face="Arial, Helvetica"><font size="-1">
<a href="roxdictionary2.html">THE AMERICAN DICTIONARY OF CRIMINAL JUSTICE: KEY TERMS AND MAJOR COURT CASES, 2nd ed.</a>
</font></font></b></td></tr>


and then it goes on for about 100 books like this.

The point is we have people who check NO books and the form succesfully sends an essentially useless email to us. I'm open to using an entirely different script as long as it has this capability. Basically, we want to be sent a list of information about the user (with many required fields) and then have them check which titles they want (at least one required).

THANKS FOR YOUR HELP!!!

Chris

I
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

hey,
Below is an example I created for a class I taught a few months ago to some of the IT programmers here who were interested in learning basic web development. I included a number of comments, hopefully they will suffice to help you adapt this to your form. Let me know if you have any questions.

Code: [ Select ]

<html>
<head>
<title>Example</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

<script LANGUAGE="JavaScript" TYPE="text/javascript">
/* Declare global variables for the error message */
    var invalid_errors = "";
    var blank_errors = "";
    var error = "";

/*instantiate and populate and array containing the field names for each required field. */
    var reqs = new Array();
        reqs[0] = "name";
        reqs[1] = "address";
        reqs[2] = "phone";
        reqs[3] = "state";
        reqs[4] = "zip";
        reqs[5] = "email";
        reqs[6] = "birthdate";
        reqs[7] = "account";
        reqs[8] = "pin";
        reqs[9] = "credittype";
        reqs[10] = "creditaccount";
        reqs[11] = "creditexp";

/*
    validate required the form object as input. It depends upon two other functions:
    isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
    it returns false and cancels form submission. It also concats all errors and displays them
    in a single alert popup that designates whether a required value was omitted or whether a
    value entered was invalid.
*/
    function validate(obj){
        for(i=0;(i<reqs.length);i++){
            element = eval(obj.elements[reqs[i]]);
            if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
            else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
        }


        if(blank_errors.length != 0 || invalid_errors.length != 0){
            if(blank_errors.length != 0){ error += "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
            if(invalid_errors.length != 0){ error += "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
            alert(error);
            return false;
        }
        else{ return true; }
    }

/*
    isBlank simply tests whether a value is blank or not.
    It returns true if the value is blank,
    It returns false if the value has ANY value. The type of value does not matter.
    isBlank requires a form element object as an argument.
*/
    isBlanke
    function isBlank(obj){
        if(obj.value == ""){ return true; }
        else{ return false; }

    }

/*
    doTrim simply chomps whitespace from boths sides of a value.
    It will leave whitespace inside of the input string alone.
    doTrim is not depenedant on any other function and requires
    a form object as an arguement. It also requires that the array
    of required elements be instantiated.
*/
    function doTrim(obj){
        if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
        obj.value = obj.value.replace(/^\s+/g,"");
        obj.value = obj.value.replace(/\s+$/g,"");
        return true;
    }


/*
    isInvalid tests whether values pass various validity checks, based on the value itself.
    The function takes two arguments, one is a form element object, the other is an integer
    that should correspond an array element in the required field array. If a given field
    passes its validity test, or if the field name is not listed in the switch logic,
    the function will return false. If the string does not pass it the validity check, the function
    returns true.
*/
    function isInvalid(obj,item){
        switch(reqs[item]) {
            case "name": if(!obj.value.match(/[a-zA-Z ]+/)){ obj.value = ""; return true; }
                break;
            case "phone": if(!obj.value.match(/[\d]{3}-[\d]{3}-[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "state": if(!obj.value.match(/[A-Z]{2}/)){ obj.value = ""; return true; }
                break;
            case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
                break;
            case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
                break;
            case "birthdate": if(!obj.value.match(/[\d]{2}\/[\d]{2}\/[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "pin": if(!obj.value.match(/[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "account": if(!obj.value.match(/[\d]{6}/)){ obj.value = ""; return true; }
                break;
            case "creditaccount": if(!obj.value.match(/[\d]{12}|[\d]{16}/)){ obj.value = ""; return true; }
                break;
            case "creditexp": if(!obj.value.match(/[\d]{2}\/[\d]{2}/)){ obj.value = ""; return true; }
                break;
            default: return false;
        }
        return false;
    }

</script>

</head>
<form NAME="form1" ACTION="form.html" METHOD="post" onSubmit="return validate(this);">
<table border="1" ALIGN="center" bgCOLOR="#cccccc">
<tr><td>Name:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="name" ID="Name" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="address" ID="Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>City:</td><td><input TYPE="text" NAME="city" ID="City" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>State:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="state" ID="State" SIZE="3" MAXLENGTH="2" onBlur="doTrim(this);"></td></tr>
<tr><td>ZIP:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="zip" ID="ZIP" SIZE="11" MAXLENGTH="10" onBlur="doTrim(this);"></td></tr>
<tr><td>Phone:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="phone" ID="Phone" SIZE="13" MAXLENGTH="12" onBlur="doTrim(this);"> (555-555-5555)</td></tr>
<tr><td>E-Mail Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>Date of Birth:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="birthdate" ID="Date of Birth" SIZE="10" onBlur="doTrim(this);"> (MM/DD/YYYY)</td></tr>
<tr><td VALIGN="top">Seating Preferences:</td>
<td>
<select NAME="SeatingPref" MULTIPLE SIZE="5">
<option VALUE="Aisle">Aisle</option>
<option VALUE="Center">Center</option>
<option VALUE="Window">Window</option>
<option VALUE="Forward">Forward</option>
<option VALUE="Rear">Rear</option>
</select>
</td>
</tr>
<tr><td VALIGN="top">Meal Preference:</td>
<td>
<input TYPE="radio" NAME="MealPref" VALUE="Standard" CHECKED> Standard
<input TYPE="radio" NAME="MealPref" VALUE="Low-Cal"> Low-Cal
<input TYPE="radio" NAME="MealPref" VALUE="Low-Salt"> Low-Salt<br>
<input TYPE="radio" NAME="MealPref" VALUE="Kosher"> Kosher
<input TYPE="radio" NAME="MealPref" VALUE="Vegetarian"> Vegetarian
</td>
</tr>
<tr><td VALIGN="top">Information Request:</td>
<td>
<input TYPE="checkbox" NAME="InfoReq" VALUE="CarRental"> Car Rental
<input TYPE="checkbox" NAME="InfoReq" VALUE="PublicTransit"> Public Transit
<input TYPE="checkbox" NAME="InfoReq" VALUE="Lodging"> Lodging<br>
<input TYPE="checkbox" NAME="InfoReq" VALUE="Attractions"> Tourist Attractions
</td>
</tr>
<tr><td>Travel Account:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="account" ID="Travel Account" SIZE="7" MAXLENGTH="6" onBlur="doTrim(this);"></td></tr>
<tr><td>Travel Account PIN:<font COLOR="#ff0000">*</font></td><td><input TYPE="password" NAME="pin" ID="Travel Account PIN" SIZE="5" MAXLENGTH="4" onBlur="doTrim(this);"></td></tr>
<tr><td VALIGN="top">Credit Card Type:<font COLOR="#ff0000">*</font></td>
<td>
<select NAME="credittype" ID="Credit Card Type">
<option VALUE="">Please select one...</option>
<option VALUE="amex">American Express</option>
<option VALUE="discover">Discover</option>
<option VALUE="mc">MasterCard</option>
<option VALUE="visa">Visa</option>
</select>
</td>
</tr>
<tr><td>Credit Card Number:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditaccount" ID="Credit Card Number" SIZE="17" MAXLENGTH="16" onBlur="doTrim(this);"> (No spaces please)</td></tr>
<tr><td>Expiration Date:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditexp" ID="Expiration Date" SIZE="6" MAXLENGTH="5" onBlur="doTrim(this);"> (MM/YY)</td></tr>
<tr><td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
</tr>
</table>
<p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Example</title>
  4. <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
  5. <script LANGUAGE="JavaScript" TYPE="text/javascript">
  6. /* Declare global variables for the error message */
  7.     var invalid_errors = "";
  8.     var blank_errors = "";
  9.     var error = "";
  10. /*instantiate and populate and array containing the field names for each required field. */
  11.     var reqs = new Array();
  12.         reqs[0] = "name";
  13.         reqs[1] = "address";
  14.         reqs[2] = "phone";
  15.         reqs[3] = "state";
  16.         reqs[4] = "zip";
  17.         reqs[5] = "email";
  18.         reqs[6] = "birthdate";
  19.         reqs[7] = "account";
  20.         reqs[8] = "pin";
  21.         reqs[9] = "credittype";
  22.         reqs[10] = "creditaccount";
  23.         reqs[11] = "creditexp";
  24. /*
  25.     validate required the form object as input. It depends upon two other functions:
  26.     isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
  27.     it returns false and cancels form submission. It also concats all errors and displays them
  28.     in a single alert popup that designates whether a required value was omitted or whether a
  29.     value entered was invalid.
  30. */
  31.     function validate(obj){
  32.         for(i=0;(i<reqs.length);i++){
  33.             element = eval(obj.elements[reqs[i]]);
  34.             if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
  35.             else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
  36.         }
  37.         if(blank_errors.length != 0 || invalid_errors.length != 0){
  38.             if(blank_errors.length != 0){ error += "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
  39.             if(invalid_errors.length != 0){ error += "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
  40.             alert(error);
  41.             return false;
  42.         }
  43.         else{ return true; }
  44.     }
  45. /*
  46.     isBlank simply tests whether a value is blank or not.
  47.     It returns true if the value is blank,
  48.     It returns false if the value has ANY value. The type of value does not matter.
  49.     isBlank requires a form element object as an argument.
  50. */
  51.     isBlanke
  52.     function isBlank(obj){
  53.         if(obj.value == ""){ return true; }
  54.         else{ return false; }
  55.     }
  56. /*
  57.     doTrim simply chomps whitespace from boths sides of a value.
  58.     It will leave whitespace inside of the input string alone.
  59.     doTrim is not depenedant on any other function and requires
  60.     a form object as an arguement. It also requires that the array
  61.     of required elements be instantiated.
  62. */
  63.     function doTrim(obj){
  64.         if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
  65.         obj.value = obj.value.replace(/^\s+/g,"");
  66.         obj.value = obj.value.replace(/\s+$/g,"");
  67.         return true;
  68.     }
  69. /*
  70.     isInvalid tests whether values pass various validity checks, based on the value itself.
  71.     The function takes two arguments, one is a form element object, the other is an integer
  72.     that should correspond an array element in the required field array. If a given field
  73.     passes its validity test, or if the field name is not listed in the switch logic,
  74.     the function will return false. If the string does not pass it the validity check, the function
  75.     returns true.
  76. */
  77.     function isInvalid(obj,item){
  78.         switch(reqs[item]) {
  79.             case "name": if(!obj.value.match(/[a-zA-Z ]+/)){ obj.value = ""; return true; }
  80.                 break;
  81.             case "phone": if(!obj.value.match(/[\d]{3}-[\d]{3}-[\d]{4}/)){ obj.value = ""; return true; }
  82.                 break;
  83.             case "state": if(!obj.value.match(/[A-Z]{2}/)){ obj.value = ""; return true; }
  84.                 break;
  85.             case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
  86.                 break;
  87.             case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
  88.                 break;
  89.             case "birthdate": if(!obj.value.match(/[\d]{2}\/[\d]{2}\/[\d]{4}/)){ obj.value = ""; return true; }
  90.                 break;
  91.             case "pin": if(!obj.value.match(/[\d]{4}/)){ obj.value = ""; return true; }
  92.                 break;
  93.             case "account": if(!obj.value.match(/[\d]{6}/)){ obj.value = ""; return true; }
  94.                 break;
  95.             case "creditaccount": if(!obj.value.match(/[\d]{12}|[\d]{16}/)){ obj.value = ""; return true; }
  96.                 break;
  97.             case "creditexp": if(!obj.value.match(/[\d]{2}\/[\d]{2}/)){ obj.value = ""; return true; }
  98.                 break;
  99.             default: return false;
  100.         }
  101.         return false;
  102.     }
  103. </script>
  104. </head>
  105. <form NAME="form1" ACTION="form.html" METHOD="post" onSubmit="return validate(this);">
  106. <table border="1" ALIGN="center" bgCOLOR="#cccccc">
  107. <tr><td>Name:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="name" ID="Name" SIZE="30" onBlur="doTrim(this);"></td></tr>
  108. <tr><td>Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="address" ID="Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
  109. <tr><td>City:</td><td><input TYPE="text" NAME="city" ID="City" SIZE="30" onBlur="doTrim(this);"></td></tr>
  110. <tr><td>State:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="state" ID="State" SIZE="3" MAXLENGTH="2" onBlur="doTrim(this);"></td></tr>
  111. <tr><td>ZIP:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="zip" ID="ZIP" SIZE="11" MAXLENGTH="10" onBlur="doTrim(this);"></td></tr>
  112. <tr><td>Phone:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="phone" ID="Phone" SIZE="13" MAXLENGTH="12" onBlur="doTrim(this);"> (555-555-5555)</td></tr>
  113. <tr><td>E-Mail Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
  114. <tr><td>Date of Birth:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="birthdate" ID="Date of Birth" SIZE="10" onBlur="doTrim(this);"> (MM/DD/YYYY)</td></tr>
  115. <tr><td VALIGN="top">Seating Preferences:</td>
  116. <td>
  117. <select NAME="SeatingPref" MULTIPLE SIZE="5">
  118. <option VALUE="Aisle">Aisle</option>
  119. <option VALUE="Center">Center</option>
  120. <option VALUE="Window">Window</option>
  121. <option VALUE="Forward">Forward</option>
  122. <option VALUE="Rear">Rear</option>
  123. </select>
  124. </td>
  125. </tr>
  126. <tr><td VALIGN="top">Meal Preference:</td>
  127. <td>
  128. <input TYPE="radio" NAME="MealPref" VALUE="Standard" CHECKED> Standard
  129. <input TYPE="radio" NAME="MealPref" VALUE="Low-Cal"> Low-Cal
  130. <input TYPE="radio" NAME="MealPref" VALUE="Low-Salt"> Low-Salt<br>
  131. <input TYPE="radio" NAME="MealPref" VALUE="Kosher"> Kosher
  132. <input TYPE="radio" NAME="MealPref" VALUE="Vegetarian"> Vegetarian
  133. </td>
  134. </tr>
  135. <tr><td VALIGN="top">Information Request:</td>
  136. <td>
  137. <input TYPE="checkbox" NAME="InfoReq" VALUE="CarRental"> Car Rental
  138. <input TYPE="checkbox" NAME="InfoReq" VALUE="PublicTransit"> Public Transit
  139. <input TYPE="checkbox" NAME="InfoReq" VALUE="Lodging"> Lodging<br>
  140. <input TYPE="checkbox" NAME="InfoReq" VALUE="Attractions"> Tourist Attractions
  141. </td>
  142. </tr>
  143. <tr><td>Travel Account:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="account" ID="Travel Account" SIZE="7" MAXLENGTH="6" onBlur="doTrim(this);"></td></tr>
  144. <tr><td>Travel Account PIN:<font COLOR="#ff0000">*</font></td><td><input TYPE="password" NAME="pin" ID="Travel Account PIN" SIZE="5" MAXLENGTH="4" onBlur="doTrim(this);"></td></tr>
  145. <tr><td VALIGN="top">Credit Card Type:<font COLOR="#ff0000">*</font></td>
  146. <td>
  147. <select NAME="credittype" ID="Credit Card Type">
  148. <option VALUE="">Please select one...</option>
  149. <option VALUE="amex">American Express</option>
  150. <option VALUE="discover">Discover</option>
  151. <option VALUE="mc">MasterCard</option>
  152. <option VALUE="visa">Visa</option>
  153. </select>
  154. </td>
  155. </tr>
  156. <tr><td>Credit Card Number:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditaccount" ID="Credit Card Number" SIZE="17" MAXLENGTH="16" onBlur="doTrim(this);"> (No spaces please)</td></tr>
  157. <tr><td>Expiration Date:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditexp" ID="Expiration Date" SIZE="6" MAXLENGTH="5" onBlur="doTrim(this);"> (MM/YY)</td></tr>
  158. <tr><td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
  159. </tr>
  160. </table>
  161. <p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
  162. </form>
  163. </body>
  164. </html>
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Here's a isNumeric JavaScript function. I've posted it before, on Ozzu, but you might find it useful:

Code: [ Select ]
function isNumeric(input){
 characters = "0123456789.";
 response = true;
 for(i=0;(i<input.length && response);i++){
  if(characters.indexOf(input.charAt(i)) == -1){ response = false; }
 }
 return response;
}
  1. function isNumeric(input){
  2.  characters = "0123456789.";
  3.  response = true;
  4.  for(i=0;(i<input.length && response);i++){
  5.   if(characters.indexOf(input.charAt(i)) == -1){ response = false; }
  6.  }
  7.  return response;
  8. }


.c
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Oh yeah.... this would, of course, require JavaScript to be enabled. If that will post a significant problem, you should also look into editing your server-side script that processes the form submisstion.

However, most people competent enough to disable JavaScript are probably also saavy enough to realize they need to fill in an order before submitting it...

.c
  • plumloopy
  • Newbie
  • Newbie
  • plumloopy
  • Posts: 5

Post 3+ Months Ago

Carnix,

Thanks for your reply, this is important.

I see much of value in your post, but I'm not sure where the solution lies. I see where it rejects blank posts and improper syntax (in what would be an appropriate way) but can this be applied to checkboxes?

It would be like requiring a user to check at LEAST one box in the "Information Request" field of your form. In my case, there are around 100 boxes but often users check none (multiple checks are allowed and okay).

Chris
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

mm. I think that isn't a problem... let me think on it. Also.. I think I posted an old version of that script (if you click the button twice,it doubles the output.... oops). I'll revise and repost.

.c
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

Try this:

Code: [ Select ]
<html>
<head>
<title>Example</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

<script LANGUAGE="JavaScript" TYPE="text/javascript">
/*instantiate and populate and array containing the field names for each required field. */
    var reqs = new Array();
        reqs[0] = "name";
        reqs[1] = "address";
        reqs[2] = "phone";
        reqs[3] = "state";
        reqs[4] = "zip";
        reqs[5] = "email";
        reqs[6] = "birthdate";
        reqs[7] = "InfoReq";
        reqs[8] = "account";
        reqs[9] = "pin";
        reqs[10] = "credittype";
        reqs[11] = "creditaccount";
        reqs[12] = "creditexp";

/*
    validate required the form object as input. It depends upon two other functions:
    isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
    it returns false and cancels form submission. It also concats all errors and displays them
    in a single alert popup that designates whether a required value was omitted or whether a
    value entered was invalid.
*/
    function validate(obj){
        blank_errors = "";
        invalid_errors = "";
        error_message = ""

        for(i=0;(i<reqs.length);i++){
            element = eval(obj.elements[reqs[i]]);
            if(obj.elements[reqs[i]].length > 0){
                if(obj.elements[reqs[i]][0].type == "checkbox"){
                    if(!hasChecks(obj.elements[reqs[i]])){ blank_errors += " - "+obj.elements[reqs[i]][0].id+"\n"; }
                }
            }
            else if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
            else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
        }


        if(blank_errors.length != 0 || invalid_errors.length != 0){
            if(blank_errors.length != 0){ blank_errors = "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
            if(invalid_errors.length != 0){ invalid_errors = "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
            error_message = blank_errors + invalid_errors;
            alert(error_message);
            return false;
        }
        else{return true;}
    }

/*
    isBlank simply tests whether a value is blank or not.
    It returns true if the value is blank,a
    It returns false if the value has ANY value. The type of value does not matter.
    isBlank requires a form element object as an argument.
*/
    function isBlank(obj){
        if(obj.value == ""){ return true; }
        else{ return false; }

    }

/*
    hasChecks simply tests whether a set of checkbox items has at least one checked.
    It returns true if ANY item is checked
    It returns false if not items are checked
    hasChecks requires a form element object that is a set of checkboxes (one box will not cause an error).
    The value of the items is not important.
*/
    function hasChecks(obj){
        for(j=0;(j<obj.length);j++){
            if(obj[j].checked){return true;}
        }
        return false;
    }

/*
    doTrim simply chomps whitespace from boths sides of a value.
    It will leave whitespace inside of the input string alone.
    doTrim is not depenedant on any other function and requires
    a form object as an arguement. It also requires that the array
    of required elements be instantiated.
*/
    function doTrim(obj){
        if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
        obj.value = obj.value.replace(/^\s+/g,"");
        obj.value = obj.value.replace(/\s+$/g,"");
        return true;
    }


/*
    isInvalid tests whether values pass various validity checks, based on the value itself.
    The function takes two arguments, one is a form element object, the other is an integer
    that should correspond an array element in the required field array. If a given field
    passes its validity test, or if the field name is not listed in the switch logic,
    the function will return false. If the string does not pass it the validity check, the function
    returns true.
*/
    function isInvalid(obj,item){
        switch(reqs[item]) {
            case "name": if(!obj.value.match(/[a-zA-Z ]+/)){ obj.value = ""; return true; }
                break;
            case "phone": if(!obj.value.match(/[\d]{3}-[\d]{3}-[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "state": if(!obj.value.match(/[A-Z]{2}/)){ obj.value = ""; return true; }
                break;
            case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
                break;
            case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
                break;
            case "birthdate": if(!obj.value.match(/[\d]{2}\/[\d]{2}\/[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "pin": if(!obj.value.match(/[\d]{4}/)){ obj.value = ""; return true; }
                break;
            case "account": if(!obj.value.match(/[\d]{6}/)){ obj.value = ""; return true; }
                break;
            case "creditaccount": if(!obj.value.match(/[\d]{12}|[\d]{16}/)){ obj.value = ""; return true; }
                break;
            case "creditexp": if(!obj.value.match(/[\d]{2}\/[\d]{2}/)){ obj.value = ""; return true; }
                break;
            default: return false;
        }
        return false;
    }

</script>

</head>
<form NAME="form1" ACTION="form.html" METHOD="post" onSubmit="return validate(this);">
<table border="1" ALIGN="center" bgCOLOR="#cccccc">
<tr><td>Name:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="name" ID="Name" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="address" ID="Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>City:</td><td><input TYPE="text" NAME="city" ID="City" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>State:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="state" ID="State" SIZE="3" MAXLENGTH="2" onBlur="doTrim(this);"></td></tr>
<tr><td>ZIP:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="zip" ID="ZIP" SIZE="11" MAXLENGTH="10" onBlur="doTrim(this);"></td></tr>
<tr><td>Phone:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="phone" ID="Phone" SIZE="13" MAXLENGTH="12" onBlur="doTrim(this);"> (555-555-5555)</td></tr>
<tr><td>E-Mail Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
<tr><td>Date of Birth:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="birthdate" ID="Date of Birth" SIZE="10" onBlur="doTrim(this);"> (MM/DD/YYYY)</td></tr>
<tr><td VALIGN="top">Seating Preferences:</td>
<td>
<select NAME="SeatingPref" ID="Seating Preferences" SIZE="5" MULTIPLE>
<option VALUE="Aisle">Aisle</option>
<option VALUE="Center">Center</option>
<option VALUE="Window">Window</option>
<option VALUE="Forward">Forward</option>
<option VALUE="Rear">Rear</option>
</select>
</td>
</tr>
<tr><td VALIGN="top">Meal Preference:</td>
<td>
<input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Standard" CHECKED> Standard
<input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Low-Cal"> Low-Cal
<input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Low-Salt"> Low-Salt<br>
<input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Kosher"> Kosher
<input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Vegetarian"> Vegetarian
</td>
</tr>
<tr><td VALIGN="top">Information Request:<font COLOR="#ff0000">*</font></td>
<td>
<input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="CarRental"> Car Rental
<input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="PublicTransit"> Public Transit
<input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="Lodging"> Lodging<br>
<input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="Attractions"> Tourist Attractions
</td>
</tr>
<tr><td>Travel Account:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="account" ID="Travel Account" SIZE="7" MAXLENGTH="6" onBlur="doTrim(this);"></td></tr>
<tr><td>Travel Account PIN:<font COLOR="#ff0000">*</font></td><td><input TYPE="password" NAME="pin" ID="Travel Account PIN" SIZE="5" MAXLENGTH="4" onBlur="doTrim(this);"></td></tr>
<tr><td VALIGN="top">Credit Card Type:<font COLOR="#ff0000">*</font></td>
<td>
<select NAME="credittype" ID="Credit Card Type">
<option VALUE="">Please select one...</option>
<option VALUE="amex">American Express</option>
<option VALUE="discover">Discover</option>
<option VALUE="mc">MasterCard</option>
<option VALUE="visa">Visa</option>
</select>
</td>
</tr>
<tr><td>Credit Card Number:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditaccount" ID="Credit Card Number" SIZE="17" MAXLENGTH="16" onBlur="doTrim(this);"> (No spaces please)</td></tr>
<tr><td>Expiration Date:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditexp" ID="Expiration Date" SIZE="6" MAXLENGTH="5" onBlur="doTrim(this);"> (MM/YY)</td></tr>
<tr><td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
</tr>
</table>
<p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Example</title>
  4. <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
  5. <script LANGUAGE="JavaScript" TYPE="text/javascript">
  6. /*instantiate and populate and array containing the field names for each required field. */
  7.     var reqs = new Array();
  8.         reqs[0] = "name";
  9.         reqs[1] = "address";
  10.         reqs[2] = "phone";
  11.         reqs[3] = "state";
  12.         reqs[4] = "zip";
  13.         reqs[5] = "email";
  14.         reqs[6] = "birthdate";
  15.         reqs[7] = "InfoReq";
  16.         reqs[8] = "account";
  17.         reqs[9] = "pin";
  18.         reqs[10] = "credittype";
  19.         reqs[11] = "creditaccount";
  20.         reqs[12] = "creditexp";
  21. /*
  22.     validate required the form object as input. It depends upon two other functions:
  23.     isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
  24.     it returns false and cancels form submission. It also concats all errors and displays them
  25.     in a single alert popup that designates whether a required value was omitted or whether a
  26.     value entered was invalid.
  27. */
  28.     function validate(obj){
  29.         blank_errors = "";
  30.         invalid_errors = "";
  31.         error_message = ""
  32.         for(i=0;(i<reqs.length);i++){
  33.             element = eval(obj.elements[reqs[i]]);
  34.             if(obj.elements[reqs[i]].length > 0){
  35.                 if(obj.elements[reqs[i]][0].type == "checkbox"){
  36.                     if(!hasChecks(obj.elements[reqs[i]])){ blank_errors += " - "+obj.elements[reqs[i]][0].id+"\n"; }
  37.                 }
  38.             }
  39.             else if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
  40.             else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
  41.         }
  42.         if(blank_errors.length != 0 || invalid_errors.length != 0){
  43.             if(blank_errors.length != 0){ blank_errors = "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
  44.             if(invalid_errors.length != 0){ invalid_errors = "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
  45.             error_message = blank_errors + invalid_errors;
  46.             alert(error_message);
  47.             return false;
  48.         }
  49.         else{return true;}
  50.     }
  51. /*
  52.     isBlank simply tests whether a value is blank or not.
  53.     It returns true if the value is blank,a
  54.     It returns false if the value has ANY value. The type of value does not matter.
  55.     isBlank requires a form element object as an argument.
  56. */
  57.     function isBlank(obj){
  58.         if(obj.value == ""){ return true; }
  59.         else{ return false; }
  60.     }
  61. /*
  62.     hasChecks simply tests whether a set of checkbox items has at least one checked.
  63.     It returns true if ANY item is checked
  64.     It returns false if not items are checked
  65.     hasChecks requires a form element object that is a set of checkboxes (one box will not cause an error).
  66.     The value of the items is not important.
  67. */
  68.     function hasChecks(obj){
  69.         for(j=0;(j<obj.length);j++){
  70.             if(obj[j].checked){return true;}
  71.         }
  72.         return false;
  73.     }
  74. /*
  75.     doTrim simply chomps whitespace from boths sides of a value.
  76.     It will leave whitespace inside of the input string alone.
  77.     doTrim is not depenedant on any other function and requires
  78.     a form object as an arguement. It also requires that the array
  79.     of required elements be instantiated.
  80. */
  81.     function doTrim(obj){
  82.         if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
  83.         obj.value = obj.value.replace(/^\s+/g,"");
  84.         obj.value = obj.value.replace(/\s+$/g,"");
  85.         return true;
  86.     }
  87. /*
  88.     isInvalid tests whether values pass various validity checks, based on the value itself.
  89.     The function takes two arguments, one is a form element object, the other is an integer
  90.     that should correspond an array element in the required field array. If a given field
  91.     passes its validity test, or if the field name is not listed in the switch logic,
  92.     the function will return false. If the string does not pass it the validity check, the function
  93.     returns true.
  94. */
  95.     function isInvalid(obj,item){
  96.         switch(reqs[item]) {
  97.             case "name": if(!obj.value.match(/[a-zA-Z ]+/)){ obj.value = ""; return true; }
  98.                 break;
  99.             case "phone": if(!obj.value.match(/[\d]{3}-[\d]{3}-[\d]{4}/)){ obj.value = ""; return true; }
  100.                 break;
  101.             case "state": if(!obj.value.match(/[A-Z]{2}/)){ obj.value = ""; return true; }
  102.                 break;
  103.             case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
  104.                 break;
  105.             case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
  106.                 break;
  107.             case "birthdate": if(!obj.value.match(/[\d]{2}\/[\d]{2}\/[\d]{4}/)){ obj.value = ""; return true; }
  108.                 break;
  109.             case "pin": if(!obj.value.match(/[\d]{4}/)){ obj.value = ""; return true; }
  110.                 break;
  111.             case "account": if(!obj.value.match(/[\d]{6}/)){ obj.value = ""; return true; }
  112.                 break;
  113.             case "creditaccount": if(!obj.value.match(/[\d]{12}|[\d]{16}/)){ obj.value = ""; return true; }
  114.                 break;
  115.             case "creditexp": if(!obj.value.match(/[\d]{2}\/[\d]{2}/)){ obj.value = ""; return true; }
  116.                 break;
  117.             default: return false;
  118.         }
  119.         return false;
  120.     }
  121. </script>
  122. </head>
  123. <form NAME="form1" ACTION="form.html" METHOD="post" onSubmit="return validate(this);">
  124. <table border="1" ALIGN="center" bgCOLOR="#cccccc">
  125. <tr><td>Name:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="name" ID="Name" SIZE="30" onBlur="doTrim(this);"></td></tr>
  126. <tr><td>Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="address" ID="Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
  127. <tr><td>City:</td><td><input TYPE="text" NAME="city" ID="City" SIZE="30" onBlur="doTrim(this);"></td></tr>
  128. <tr><td>State:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="state" ID="State" SIZE="3" MAXLENGTH="2" onBlur="doTrim(this);"></td></tr>
  129. <tr><td>ZIP:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="zip" ID="ZIP" SIZE="11" MAXLENGTH="10" onBlur="doTrim(this);"></td></tr>
  130. <tr><td>Phone:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="phone" ID="Phone" SIZE="13" MAXLENGTH="12" onBlur="doTrim(this);"> (555-555-5555)</td></tr>
  131. <tr><td>E-Mail Address:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="30" onBlur="doTrim(this);"></td></tr>
  132. <tr><td>Date of Birth:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="birthdate" ID="Date of Birth" SIZE="10" onBlur="doTrim(this);"> (MM/DD/YYYY)</td></tr>
  133. <tr><td VALIGN="top">Seating Preferences:</td>
  134. <td>
  135. <select NAME="SeatingPref" ID="Seating Preferences" SIZE="5" MULTIPLE>
  136. <option VALUE="Aisle">Aisle</option>
  137. <option VALUE="Center">Center</option>
  138. <option VALUE="Window">Window</option>
  139. <option VALUE="Forward">Forward</option>
  140. <option VALUE="Rear">Rear</option>
  141. </select>
  142. </td>
  143. </tr>
  144. <tr><td VALIGN="top">Meal Preference:</td>
  145. <td>
  146. <input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Standard" CHECKED> Standard
  147. <input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Low-Cal"> Low-Cal
  148. <input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Low-Salt"> Low-Salt<br>
  149. <input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Kosher"> Kosher
  150. <input TYPE="radio" NAME="MealPref" ID="Meal Preference" VALUE="Vegetarian"> Vegetarian
  151. </td>
  152. </tr>
  153. <tr><td VALIGN="top">Information Request:<font COLOR="#ff0000">*</font></td>
  154. <td>
  155. <input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="CarRental"> Car Rental
  156. <input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="PublicTransit"> Public Transit
  157. <input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="Lodging"> Lodging<br>
  158. <input TYPE="checkbox" NAME="InfoReq" ID="Information Request" VALUE="Attractions"> Tourist Attractions
  159. </td>
  160. </tr>
  161. <tr><td>Travel Account:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="account" ID="Travel Account" SIZE="7" MAXLENGTH="6" onBlur="doTrim(this);"></td></tr>
  162. <tr><td>Travel Account PIN:<font COLOR="#ff0000">*</font></td><td><input TYPE="password" NAME="pin" ID="Travel Account PIN" SIZE="5" MAXLENGTH="4" onBlur="doTrim(this);"></td></tr>
  163. <tr><td VALIGN="top">Credit Card Type:<font COLOR="#ff0000">*</font></td>
  164. <td>
  165. <select NAME="credittype" ID="Credit Card Type">
  166. <option VALUE="">Please select one...</option>
  167. <option VALUE="amex">American Express</option>
  168. <option VALUE="discover">Discover</option>
  169. <option VALUE="mc">MasterCard</option>
  170. <option VALUE="visa">Visa</option>
  171. </select>
  172. </td>
  173. </tr>
  174. <tr><td>Credit Card Number:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditaccount" ID="Credit Card Number" SIZE="17" MAXLENGTH="16" onBlur="doTrim(this);"> (No spaces please)</td></tr>
  175. <tr><td>Expiration Date:<font COLOR="#ff0000">*</font></td><td><input TYPE="text" NAME="creditexp" ID="Expiration Date" SIZE="6" MAXLENGTH="5" onBlur="doTrim(this);"> (MM/YY)</td></tr>
  176. <tr><td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
  177. </tr>
  178. </table>
  179. <p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
  180. </form>
  181. </body>
  182. </html>
  • plumloopy
  • Newbie
  • Newbie
  • plumloopy
  • Posts: 5

Post 3+ Months Ago

Thanks so much for your help! I'm definitely getting it to reject empty requests but now I'm having trouble getting it to communicate with the old formmail program. To be sure, a lesser problem but the old formmail inserted a subject and header into the email, which is helpful. I've tried countless variations to basically preserve the previous behavior while still utilizing your helpful java code, but the two don't seem to work together.

Here's my code thus far (minus most of the books):

Code: [ Select ]
<html>
<head>
<title>Roxbury Examination Copy Order</title>
<meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">

<script LANGUAGE="JavaScript" TYPE="text/javascript">
/*instantiate and populate and array containing the field names for each required field. */
  var reqs = new Array();
   reqs[0] = "name";
     reqs[1] = "Institution";
   reqs[2] = "Department";
   reqs[3] = "address";
   reqs[4] = "state";
   reqs[5] = "zip";
   reqs[6] = "phone";
   reqs[7] = "email";
   reqs[8] = "adoptiondecisiondeadline";
   reqs[9] = "book";
   reqs[10] = "likelihoodoftextchange";

/*
  validate required the form object as input. It depends upon two other functions:
  isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
  it returns false and cancels form submission. It also concats all errors and displays them
  in a single alert popup that designates whether a required value was omitted or whether a
  value entered was invalid.
*/
  function validate(obj){
   blank_errors = "";
   invalid_errors = "";
   error_message = ""

   for(i=0;(i<reqs.length);i++){
     element = eval(obj.elements[reqs[i]]);
     if(obj.elements[reqs[i]].length > 0){
      if(obj.elements[reqs[i]][0].type == "checkbox"){
        if(!hasChecks(obj.elements[reqs[i]])){ blank_errors += " - "+obj.elements[reqs[i]][0].id+"\n"; }
      }
     }
     else if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
     else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
   }


   if(blank_errors.length != 0 || invalid_errors.length != 0){
     if(blank_errors.length != 0){ blank_errors = "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
     if(invalid_errors.length != 0){ invalid_errors = "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
     error_message = blank_errors + invalid_errors;
     alert(error_message);
     return false;
   }
   else{return true;}
  }

/*
  isBlank simply tests whether a value is blank or not.
  It returns true if the value is blank,a
  It returns false if the value has ANY value. The type of value does not matter.
  isBlank requires a form element object as an argument.
*/
  function isBlank(obj){
   if(obj.value == ""){ return true; }
   else{ return false; }

  }

/*
  hasChecks simply tests whether a set of checkbox items has at least one checked.
  It returns true if ANY item is checked
  It returns false if not items are checked
  hasChecks requires a form element object that is a set of checkboxes (one box will not cause an error).
  The value of the items is not important.
*/
  function hasChecks(obj){
   for(j=0;(j<obj.length);j++){
     if(obj[j].checked){return true;}
   }
   return false;
  }

/*
  doTrim simply chomps whitespace from boths sides of a value.
  It will leave whitespace inside of the input string alone.
  doTrim is not depenedant on any other function and requires
  a form object as an arguement. It also requires that the array
  of required elements be instantiated.
*/
  function doTrim(obj){
   if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
   obj.value = obj.value.replace(/^\s+/g,"");
   obj.value = obj.value.replace(/\s+$/g,"");
   return true;
  }


/*
  isInvalid tests whether values pass various validity checks, based on the value itself.
  The function takes two arguments, one is a form element object, the other is an integer
  that should correspond an array element in the required field array. If a given field
  passes its validity test, or if the field name is not listed in the switch logic,
  the function will return false. If the string does not pass it the validity check, the function
  returns true.
*/
  function isInvalid(obj,item){
   switch(reqs[item]) {
     case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
      break;
     case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
      break;
     default: return false;
   }
   return false;
  }

</script>

</head>
<form method="post" action="/cgi-sys/formmail.pl" onSubmit="return validate(this);">
<input name="redirect" type="hidden" value="http://www.carrierdesign.com/roxbury/thankyou.html">
<input type="hidden" name="recipient" value="contact@carrierdesign.com">


<table width="420" height="0" border="1" align="center" cellspacing="0" bordercolor="#000000" hspace="2" vspace="1">
<tbody>
<tr><td align="center" colspan="4" height="42" bgcolor="#000090">
<font face="Arial, Helvetica"><font color="#ffffff">
<font size="+1" face="Arial, Helvetica, sans-serif">ROXBURY EXAMINATION</font></font></font>
<font face="Arial, Helvetica, sans-serif"><br>
<font color="#ffffff">
<font size="+1">COPY REQUEST FORM</font></font></font></td></tr>
</tbody></table>
 <table width="420" height="0" border="0" align="center" hspace="2" vspace="1">
  <!--DWLayoutTable-->
  <tr>
   <td colspan=4> <br> <font face="Arial, Helvetica, sans-serif">Complimentary
    examination copies may be requested by college and university instructors
    who will seriously consider the book(s) for classroom adoption at schools
    where they teach. Complimentary copies are not available to students.</font>
    <p><font face="Arial, Helvetica, sans-serif">In order to receive a complimentary
     copy, all information below must be completed. We can only ship complimentary
     copies to an institutional address.</font></p>
    <p><font face="Arial, Helvetica, sans-serif">Please enter your information
     into the required fields. All required fields are marked with an asterisk.
     The form cannot be processed without this information. Check "order"
     next to the title(s) you're requesting. Finally, click "submit" to transmit
     electronically.</font></p>
    <p><font face="Arial, Helvetica, sans-serif">If you would prefer to print
     out this form, please click on this page and select <b>File/Print</b>
     from your browser's drop-down menu. Then fax or mail the form to us
     using the contact information below.</font></p>
    <p><font face="Arial, Helvetica, sans-serif">Individuals wishing to purchase
     books for any other purpose should refer to the <a href="purchase.html">Roxbury
     Purchase Order Form</a>.</font></p>
    <p><font face="Arial, Helvetica, sans-serif"><b> <font size="-1">Roxbury
     Publishing Company</font> </b><br>
     <font size="-1">P.O. Box 491044</font> <br>
     <font size="-1">Los Angeles, CA 90049-9044</font> <br>
     <font size="-1">Tel.: (310) 473-3312</font> <br>
     <font size="-1">Fax: (310) 473-4490</font></font> <font face="Arial, Helvetica, sans-serif"><br>
     Email: <a href="mailto:roxbury@roxbury.net">roxbury@roxbury.net</a>
     </font> </td>
  </tr>
  <tr>
   <td width="43"><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
   <td width="250"><font face="Arial, Helvetica, sans-serif"><b><font color="#d03030">*</font>
    <font size="2">Name</font></b></font></td>
   <td colspan="2" width="164"><input TYPE="text" NAME="name" ID="Name" SIZE="20" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
   <td width="250"><font face="Arial, Helvetica, sans-serif"><b><font color="#d03030">*</font>
    <font size="2">Institution</font></b></font></td>
   <td colspan="2" width="164"><input type="text" NAME="Institution" ID="Institution" SIZE="20" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"></td>
   <td width="250"><b><font color="#d03030">*</font> <font face="Arial, Helvetica">
    <font size="-1">Department</font></font></b></td>
   <td colspan="2" width="164"> <input type="text" NAME="Department" ID="Department" SIZE="20" onBlur="doTrim(this);"></td>
  </tr>
  <tr>
   <td width="43"></td>
   <td width="250"><b><font color="#d03030">*</font> <font face="Arial, Helvetica"><font size="-1">Street
    address</font> </font></b></td>
   <td colspan="2" width="164"> <input TYPE="text" NAME="address" ID="Address" SIZE="20" onBlur="doTrim(this);"></td>
  </tr>
  <tr>
   <td width="43"></td>
   <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
    <font size="-1">City</font></font></b></td>
   <td colspan="2" width="164"><input TYPE="text" NAME="city" ID="City" SIZE="20" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"></td>
   <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
    <font size="-1">State</font></font></b></td>
   <td colspan="2" width="164"><input TYPE="text" NAME="state" ID="State" SIZE="20" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"></td>
   <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
    <font size="-1">Zip code</font></font></b></td>
   <td colspan="2" width="164"><input type="text" name="zip" id="Zip Code" size="20" maxlength="10" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font><font
face="Arial, Helvetica"> <font color="#000090"><font size="-1">Your class enrollment:</font>
    </font></font></b></td>
   <td colspan="2" width="164">&nbsp;</td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#ffffff">*</font><font
face="Arial, Helvetica"> <font size="-1">Fall</font></font></b></td>
   <td colspan="2" width="164"><input type="text" size="20"
name="fallenrollment"> </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#ffffff">*</font><font
face="Arial, Helvetica"> <font size="-1">Winter/Spring</font></font></b></td>
   <td colspan="2" width="164"> <input type="text" size="20"
name="winterspringenrollment"></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#ffffff">*</font><font
face="Arial, Helvetica"> <font size="-1">Summer</font></font></b></td>
   <td colspan="2" width="164"> <input type="text" size="20"
name="summerenrollment"></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font><font
face="Arial, Helvetica"> <font size="-1">Adoption decision deadline</font></font></b></td>
   <td colspan="2" width="164"> <input type="text" size="20" ID="Adoption Decision Deadline" name="adoptiondecisiondeadline" onBlur="doTrim(this);"></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font><font
face="Arial, Helvetica"> <font size="-1">Office telephone</font></font></b></td>
   <td colspan="2" width="164"><input type="text" name="phone" id="Office Phone" size="20" onBlur="doTrim(this);">
   </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#ffffff">*</font><font
face="Arial, Helvetica"> <font size="-1">Home telephone</font></font></b></td>
   <td colspan="2" width="164"><input type="text" size="20"
name="homephone"> </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font><font
face="Arial, Helvetica"> <font size="-1">E-mail address</font></font></b></td>
   <td colspan="2" width="164"><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="20" onBlur="doTrim(this);"></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font> <font
face="Arial, Helvetica"><font size="-1">Would you assign text as</font> </font></b><br>
    <font face="Arial, Helvetica"><font size="-1"><b> <font
color="#ffffff">*</font></b>(click on one)</font></font></td>
   <td colspan="2" width="164"> <input type="checkbox"
name="assigntextasrequired" value="assigntextasrequired"> <font
face="Arial, Helvetica"><font size="-1">Required</font></font></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><br> </td>
   <td colspan="2" width="174"> <input type="checkbox"
name="assigntextasrecommended" value="assigntextasrecommended"> <font
face="Arial, Helvetica"> <font size="-1">Recommended (would be stocked in bookstore)</font></font>
   </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><br> </td>
   <td colspan="2" width="164"> <input type="checkbox"
name="recommendedbutnotinbookstore" value="recommendedbutnotinstore"> <font
face="Arial, Helvetica"> <font size="-1">Recommended but not stocked in bookstore</font>
    </font></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><br> </td>
   <td colspan="2" width="164"> <input type="checkbox" name="maintext"
value="maintext"> <font face="Arial, Helvetica"><font size="-1">Main text</font></font>
   </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><br> </td>
   <td colspan="2" width="164"> <input type="checkbox"
name="supplementarytext" value="supplementarytext"> <font
face="Arial, Helvetica"> <font size="-1">Supplementary text</font></font></td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#d03030">*</font><font
face="Arial, Helvetica"> <font size="2">Likelihood of text change:</font></font></b><br>
    <font face="Arial, Helvetica"><font size="2">&nbsp;&nbsp;1-least likely</font><br>
    <font size="2" face="Arial, Helvetica">&nbsp;&nbsp;10-most likely</font></font></td>
   <td colspan="2" width="164"> <select name="likelihoodoftextchange" ID="Likelihood of Text Change" size="1">
     <option></option>
     <option>1</option>
     <option>2</option>
     <option>3</option>
     <option>4</option>
     <option>5</option>
     <option>6</option>
     <option>7</option>
     <option>8</option>
     <option>9</option>
     <option>10</option>
    </select> </td>
  </tr>
  <tr>
   <td width="43"><br> </td>
   <td width="250"><b><font color="#ffffff">*</font> <font
face="Arial, Helvetica"> <font size="2">How did you discover the Roxbury website?</font></font></b></td>
   <td colspan="2" width="164"> <input type="text" size="20"
name="howdiscoverroxnet"></td>
  </tr>
  <tr>
    </table><br>
     <table width="420" border="1" align="center" cellspacing="0" bordercolor="#000090"
hspace="2" vspace="1">

  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <b><font face="Arial"><font color="#ffffff"><font
size="-1">CLICK BELOW</font> </font></font></b></td>
   <td colspan=2 width="357" height="42" bgcolor="#000090"><b> <font
face="Arial, Helvetica"><font color="#ffffff"> <font size="-1">CHOOSE FROM CURRENT
    AND FORTHCOMING TITLES:</font> </font></font></b></td>
  </tr>
  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="al3">
    <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">&nbsp;Order</font></font></font></b></td>
   <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
    <a
href="active3.html">THE ACTIVE LEARNER: SUCCESSFUL STUDY STRATEGIES, 3rd ed.</a>
    </font></font></b></td>
  </tr>
  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="dcj2">
    <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
    <a
href="roxdictionary2.html">THE AMERICAN DICTIONARY OF CRIMINAL JUSTICE: KEY TERMS
    AND MAJOR COURT CASES, 2nd ed.</a> </font></font></b></td>
  </tr>
  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="dcj3">
    <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font
color="#009900"> <font size="+1">*</font></font></font></b><b><font
face="Arial, Helvetica"> <font size="-1"> <a href="dictionary3.html">THE AMERICAN
    DICTIONARY OF CRIMINAL JUSTICE: KEY TERMS AND MAJOR COURT CASES, 3rd ed.</a>
    <br>
    </font></font></b><b><font face="Arial, Helvetica"><font
color="#009900"> <font size="-1">available: Fall 2004</font></font></font></b><br>
   </td>
  </tr>
  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="ad4">
    <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
    <a
href="amerdrug4.html">THE AMERICAN DRUG SCENE: AN ANTHOLOGY, 4th ed.</a> </font></font></b><br>
   </td>
  </tr>
  <tr>
   <td valign="top" width="42" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="am"> <br> <b>
    <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
    <a
href="americanlegal.html">THE AMERICAN LEGAL SYSTEM: FOUNDATIONS, PROCESSES,
    AND NORMS, 1st ed.</a> </font></font></b><br> </td>
  </tr>
    <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="amsg"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="americanlegal.html">STUDENT STUDY GUIDE FOR THE AMERICAN LEGAL SYSTEM:
 FOUNDATIONS, PROCESSES, AND NORMS, 1st ed.</a> </font></font></b><br>
      </td>
     </tr>
   <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="ab2"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="answer2.html">THE ANSWER book: A REFERENCE MANUAL FOR OFFICE PERSONNEL,
 2nd ed.</a> </font></font></b></td>
     </tr>
   <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection"
value="abwbk"><br>
   <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="answer2work.html">STUDENT WORKbook FOR THE ANSWER book, 2nd ed.</a>
    </font></font></b></td>
     </tr>
   <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="acc"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font
color="#009900">     <font size="+1">*</font></font><font size="-1">
    <a href="apollo.html">APOLLO, CHALLENGER, COLUMBIA: THE DECLINE OF
THE SPACE PROGRAM (A STUDY IN ORGANIZATIONAL COMMUNICATION), 1st ed.</a>
    </font></font></b><br>
      <b><font face="Arial, Helvetica"><font color="#009900"> <font
size="-1">available: Fall 2004</font></font></font></b></td>
     </tr>
   <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="bi"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="biologycrime.html">BIOLOGY AND CRIME, 1st ed.</a> </font></font></b></td>
     </tr>
   <tr>
      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="bc5"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="bizcomm.html">BUSINESS COMMUNICATION: CONCEPTS AND APPLICATIONS IN
 AN ELECTRONIC AGE, 5th ed.</a> </font></font></b></td>
     </tr>

      <td valign="top" width="44" bgcolor="#000090"
bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="wc2"><br>
      <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
size="-1">Order</font></font></font></b></td>
   <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
href="writingcycle2.html">THE WRITING CYCLE: A FUNDAMENTAL TEXT FOR BEGINNING
 AND INTERMEDIATE WRITERS, 2nd ed.</a> </font></font></b></td>
     </tr>
  <tr>
   <td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
  </tr>
 </table>
<p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
</form>
</body>
</html>
  1. <html>
  2. <head>
  3. <title>Roxbury Examination Copy Order</title>
  4. <meta HTTP-EQUIV="content-type" CONTENT="text/html; charset=utf-8">
  5. <script LANGUAGE="JavaScript" TYPE="text/javascript">
  6. /*instantiate and populate and array containing the field names for each required field. */
  7.   var reqs = new Array();
  8.    reqs[0] = "name";
  9.      reqs[1] = "Institution";
  10.    reqs[2] = "Department";
  11.    reqs[3] = "address";
  12.    reqs[4] = "state";
  13.    reqs[5] = "zip";
  14.    reqs[6] = "phone";
  15.    reqs[7] = "email";
  16.    reqs[8] = "adoptiondecisiondeadline";
  17.    reqs[9] = "book";
  18.    reqs[10] = "likelihoodoftextchange";
  19. /*
  20.   validate required the form object as input. It depends upon two other functions:
  21.   isBlank and isInvalid. It returns true if both isBlank and isInvalid are false, otherwise
  22.   it returns false and cancels form submission. It also concats all errors and displays them
  23.   in a single alert popup that designates whether a required value was omitted or whether a
  24.   value entered was invalid.
  25. */
  26.   function validate(obj){
  27.    blank_errors = "";
  28.    invalid_errors = "";
  29.    error_message = ""
  30.    for(i=0;(i<reqs.length);i++){
  31.      element = eval(obj.elements[reqs[i]]);
  32.      if(obj.elements[reqs[i]].length > 0){
  33.       if(obj.elements[reqs[i]][0].type == "checkbox"){
  34.         if(!hasChecks(obj.elements[reqs[i]])){ blank_errors += " - "+obj.elements[reqs[i]][0].id+"\n"; }
  35.       }
  36.      }
  37.      else if(isBlank(element)){ blank_errors += " - "+element.id+"\n"; }
  38.      else{ if(isInvalid(element,i)){ invalid_errors += " - "+element.id+"\n"; } }
  39.    }
  40.    if(blank_errors.length != 0 || invalid_errors.length != 0){
  41.      if(blank_errors.length != 0){ blank_errors = "The following required fields are required,\nbut it appears you left them blank:\n" + blank_errors; }
  42.      if(invalid_errors.length != 0){ invalid_errors = "\nThe following required fields contain invalid values:\n" + invalid_errors + "\nThese invalid values have been removed,\nplease re-enter them.\n"; }
  43.      error_message = blank_errors + invalid_errors;
  44.      alert(error_message);
  45.      return false;
  46.    }
  47.    else{return true;}
  48.   }
  49. /*
  50.   isBlank simply tests whether a value is blank or not.
  51.   It returns true if the value is blank,a
  52.   It returns false if the value has ANY value. The type of value does not matter.
  53.   isBlank requires a form element object as an argument.
  54. */
  55.   function isBlank(obj){
  56.    if(obj.value == ""){ return true; }
  57.    else{ return false; }
  58.   }
  59. /*
  60.   hasChecks simply tests whether a set of checkbox items has at least one checked.
  61.   It returns true if ANY item is checked
  62.   It returns false if not items are checked
  63.   hasChecks requires a form element object that is a set of checkboxes (one box will not cause an error).
  64.   The value of the items is not important.
  65. */
  66.   function hasChecks(obj){
  67.    for(j=0;(j<obj.length);j++){
  68.      if(obj[j].checked){return true;}
  69.    }
  70.    return false;
  71.   }
  72. /*
  73.   doTrim simply chomps whitespace from boths sides of a value.
  74.   It will leave whitespace inside of the input string alone.
  75.   doTrim is not depenedant on any other function and requires
  76.   a form object as an arguement. It also requires that the array
  77.   of required elements be instantiated.
  78. */
  79.   function doTrim(obj){
  80.    if(obj.name == reqs[3]){ obj.value = obj.value.toUpperCase(); }
  81.    obj.value = obj.value.replace(/^\s+/g,"");
  82.    obj.value = obj.value.replace(/\s+$/g,"");
  83.    return true;
  84.   }
  85. /*
  86.   isInvalid tests whether values pass various validity checks, based on the value itself.
  87.   The function takes two arguments, one is a form element object, the other is an integer
  88.   that should correspond an array element in the required field array. If a given field
  89.   passes its validity test, or if the field name is not listed in the switch logic,
  90.   the function will return false. If the string does not pass it the validity check, the function
  91.   returns true.
  92. */
  93.   function isInvalid(obj,item){
  94.    switch(reqs[item]) {
  95.      case "zip": if(!obj.value.match(/(^[\d]{5}$)|(^[\d]{5}-[\d]{4}$)/)){ obj.value = ""; return true; }
  96.       break;
  97.      case "email": if(!obj.value.match(/[^@]+@[\S]+\.[\S]+/)){ obj.value = ""; return true; }
  98.       break;
  99.      default: return false;
  100.    }
  101.    return false;
  102.   }
  103. </script>
  104. </head>
  105. <form method="post" action="/cgi-sys/formmail.pl" onSubmit="return validate(this);">
  106. <input name="redirect" type="hidden" value="http://www.carrierdesign.com/roxbury/thankyou.html">
  107. <input type="hidden" name="recipient" value="contact@carrierdesign.com">
  108. <table width="420" height="0" border="1" align="center" cellspacing="0" bordercolor="#000000" hspace="2" vspace="1">
  109. <tbody>
  110. <tr><td align="center" colspan="4" height="42" bgcolor="#000090">
  111. <font face="Arial, Helvetica"><font color="#ffffff">
  112. <font size="+1" face="Arial, Helvetica, sans-serif">ROXBURY EXAMINATION</font></font></font>
  113. <font face="Arial, Helvetica, sans-serif"><br>
  114. <font color="#ffffff">
  115. <font size="+1">COPY REQUEST FORM</font></font></font></td></tr>
  116. </tbody></table>
  117.  <table width="420" height="0" border="0" align="center" hspace="2" vspace="1">
  118.   <!--DWLayoutTable-->
  119.   <tr>
  120.    <td colspan=4> <br> <font face="Arial, Helvetica, sans-serif">Complimentary
  121.     examination copies may be requested by college and university instructors
  122.     who will seriously consider the book(s) for classroom adoption at schools
  123.     where they teach. Complimentary copies are not available to students.</font>
  124.     <p><font face="Arial, Helvetica, sans-serif">In order to receive a complimentary
  125.      copy, all information below must be completed. We can only ship complimentary
  126.      copies to an institutional address.</font></p>
  127.     <p><font face="Arial, Helvetica, sans-serif">Please enter your information
  128.      into the required fields. All required fields are marked with an asterisk.
  129.      The form cannot be processed without this information. Check "order"
  130.      next to the title(s) you're requesting. Finally, click "submit" to transmit
  131.      electronically.</font></p>
  132.     <p><font face="Arial, Helvetica, sans-serif">If you would prefer to print
  133.      out this form, please click on this page and select <b>File/Print</b>
  134.      from your browser's drop-down menu. Then fax or mail the form to us
  135.      using the contact information below.</font></p>
  136.     <p><font face="Arial, Helvetica, sans-serif">Individuals wishing to purchase
  137.      books for any other purpose should refer to the <a href="purchase.html">Roxbury
  138.      Purchase Order Form</a>.</font></p>
  139.     <p><font face="Arial, Helvetica, sans-serif"><b> <font size="-1">Roxbury
  140.      Publishing Company</font> </b><br>
  141.      <font size="-1">P.O. Box 491044</font> <br>
  142.      <font size="-1">Los Angeles, CA 90049-9044</font> <br>
  143.      <font size="-1">Tel.: (310) 473-3312</font> <br>
  144.      <font size="-1">Fax: (310) 473-4490</font></font> <font face="Arial, Helvetica, sans-serif"><br>
  145.      Email: <a href="mailto:roxbury@roxbury.net">roxbury@roxbury.net</a>
  146.      </font> </td>
  147.   </tr>
  148.   <tr>
  149.    <td width="43"><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
  150.    <td width="250"><font face="Arial, Helvetica, sans-serif"><b><font color="#d03030">*</font>
  151.     <font size="2">Name</font></b></font></td>
  152.    <td colspan="2" width="164"><input TYPE="text" NAME="name" ID="Name" SIZE="20" onBlur="doTrim(this);">
  153.    </td>
  154.   </tr>
  155.   <tr>
  156.    <td width="43"><font face="Arial, Helvetica, sans-serif">&nbsp;</font></td>
  157.    <td width="250"><font face="Arial, Helvetica, sans-serif"><b><font color="#d03030">*</font>
  158.     <font size="2">Institution</font></b></font></td>
  159.    <td colspan="2" width="164"><input type="text" NAME="Institution" ID="Institution" SIZE="20" onBlur="doTrim(this);">
  160.    </td>
  161.   </tr>
  162.   <tr>
  163.    <td width="43"></td>
  164.    <td width="250"><b><font color="#d03030">*</font> <font face="Arial, Helvetica">
  165.     <font size="-1">Department</font></font></b></td>
  166.    <td colspan="2" width="164"> <input type="text" NAME="Department" ID="Department" SIZE="20" onBlur="doTrim(this);"></td>
  167.   </tr>
  168.   <tr>
  169.    <td width="43"></td>
  170.    <td width="250"><b><font color="#d03030">*</font> <font face="Arial, Helvetica"><font size="-1">Street
  171.     address</font> </font></b></td>
  172.    <td colspan="2" width="164"> <input TYPE="text" NAME="address" ID="Address" SIZE="20" onBlur="doTrim(this);"></td>
  173.   </tr>
  174.   <tr>
  175.    <td width="43"></td>
  176.    <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
  177.     <font size="-1">City</font></font></b></td>
  178.    <td colspan="2" width="164"><input TYPE="text" NAME="city" ID="City" SIZE="20" onBlur="doTrim(this);">
  179.    </td>
  180.   </tr>
  181.   <tr>
  182.    <td width="43"></td>
  183.    <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
  184.     <font size="-1">State</font></font></b></td>
  185.    <td colspan="2" width="164"><input TYPE="text" NAME="state" ID="State" SIZE="20" onBlur="doTrim(this);">
  186.    </td>
  187.   </tr>
  188.   <tr>
  189.    <td width="43"></td>
  190.    <td width="250"><b><font color="#d03030">*</font><font face="Arial, Helvetica">
  191.     <font size="-1">Zip code</font></font></b></td>
  192.    <td colspan="2" width="164"><input type="text" name="zip" id="Zip Code" size="20" maxlength="10" onBlur="doTrim(this);">
  193.    </td>
  194.   </tr>
  195.   <tr>
  196.    <td width="43"><br> </td>
  197.    <td width="250"><b><font color="#d03030">*</font><font
  198. face="Arial, Helvetica"> <font color="#000090"><font size="-1">Your class enrollment:</font>
  199.     </font></font></b></td>
  200.    <td colspan="2" width="164">&nbsp;</td>
  201.   </tr>
  202.   <tr>
  203.    <td width="43"><br> </td>
  204.    <td width="250"><b><font color="#ffffff">*</font><font
  205. face="Arial, Helvetica"> <font size="-1">Fall</font></font></b></td>
  206.    <td colspan="2" width="164"><input type="text" size="20"
  207. name="fallenrollment"> </td>
  208.   </tr>
  209.   <tr>
  210.    <td width="43"><br> </td>
  211.    <td width="250"><b><font color="#ffffff">*</font><font
  212. face="Arial, Helvetica"> <font size="-1">Winter/Spring</font></font></b></td>
  213.    <td colspan="2" width="164"> <input type="text" size="20"
  214. name="winterspringenrollment"></td>
  215.   </tr>
  216.   <tr>
  217.    <td width="43"><br> </td>
  218.    <td width="250"><b><font color="#ffffff">*</font><font
  219. face="Arial, Helvetica"> <font size="-1">Summer</font></font></b></td>
  220.    <td colspan="2" width="164"> <input type="text" size="20"
  221. name="summerenrollment"></td>
  222.   </tr>
  223.   <tr>
  224.    <td width="43"><br> </td>
  225.    <td width="250"><b><font color="#d03030">*</font><font
  226. face="Arial, Helvetica"> <font size="-1">Adoption decision deadline</font></font></b></td>
  227.    <td colspan="2" width="164"> <input type="text" size="20" ID="Adoption Decision Deadline" name="adoptiondecisiondeadline" onBlur="doTrim(this);"></td>
  228.   </tr>
  229.   <tr>
  230.    <td width="43"><br> </td>
  231.    <td width="250"><b><font color="#d03030">*</font><font
  232. face="Arial, Helvetica"> <font size="-1">Office telephone</font></font></b></td>
  233.    <td colspan="2" width="164"><input type="text" name="phone" id="Office Phone" size="20" onBlur="doTrim(this);">
  234.    </td>
  235.   </tr>
  236.   <tr>
  237.    <td width="43"><br> </td>
  238.    <td width="250"><b><font color="#ffffff">*</font><font
  239. face="Arial, Helvetica"> <font size="-1">Home telephone</font></font></b></td>
  240.    <td colspan="2" width="164"><input type="text" size="20"
  241. name="homephone"> </td>
  242.   </tr>
  243.   <tr>
  244.    <td width="43"><br> </td>
  245.    <td width="250"><b><font color="#d03030">*</font><font
  246. face="Arial, Helvetica"> <font size="-1">E-mail address</font></font></b></td>
  247.    <td colspan="2" width="164"><input TYPE="text" NAME="email" ID="E-Mail Address" SIZE="20" onBlur="doTrim(this);"></td>
  248.   </tr>
  249.   <tr>
  250.    <td width="43"><br> </td>
  251.    <td width="250"><b><font color="#d03030">*</font> <font
  252. face="Arial, Helvetica"><font size="-1">Would you assign text as</font> </font></b><br>
  253.     <font face="Arial, Helvetica"><font size="-1"><b> <font
  254. color="#ffffff">*</font></b>(click on one)</font></font></td>
  255.    <td colspan="2" width="164"> <input type="checkbox"
  256. name="assigntextasrequired" value="assigntextasrequired"> <font
  257. face="Arial, Helvetica"><font size="-1">Required</font></font></td>
  258.   </tr>
  259.   <tr>
  260.    <td width="43"><br> </td>
  261.    <td width="250"><br> </td>
  262.    <td colspan="2" width="174"> <input type="checkbox"
  263. name="assigntextasrecommended" value="assigntextasrecommended"> <font
  264. face="Arial, Helvetica"> <font size="-1">Recommended (would be stocked in bookstore)</font></font>
  265.    </td>
  266.   </tr>
  267.   <tr>
  268.    <td width="43"><br> </td>
  269.    <td width="250"><br> </td>
  270.    <td colspan="2" width="164"> <input type="checkbox"
  271. name="recommendedbutnotinbookstore" value="recommendedbutnotinstore"> <font
  272. face="Arial, Helvetica"> <font size="-1">Recommended but not stocked in bookstore</font>
  273.     </font></td>
  274.   </tr>
  275.   <tr>
  276.    <td width="43"><br> </td>
  277.    <td width="250"><br> </td>
  278.    <td colspan="2" width="164"> <input type="checkbox" name="maintext"
  279. value="maintext"> <font face="Arial, Helvetica"><font size="-1">Main text</font></font>
  280.    </td>
  281.   </tr>
  282.   <tr>
  283.    <td width="43"><br> </td>
  284.    <td width="250"><br> </td>
  285.    <td colspan="2" width="164"> <input type="checkbox"
  286. name="supplementarytext" value="supplementarytext"> <font
  287. face="Arial, Helvetica"> <font size="-1">Supplementary text</font></font></td>
  288.   </tr>
  289.   <tr>
  290.    <td width="43"><br> </td>
  291.    <td width="250"><b><font color="#d03030">*</font><font
  292. face="Arial, Helvetica"> <font size="2">Likelihood of text change:</font></font></b><br>
  293.     <font face="Arial, Helvetica"><font size="2">&nbsp;&nbsp;1-least likely</font><br>
  294.     <font size="2" face="Arial, Helvetica">&nbsp;&nbsp;10-most likely</font></font></td>
  295.    <td colspan="2" width="164"> <select name="likelihoodoftextchange" ID="Likelihood of Text Change" size="1">
  296.      <option></option>
  297.      <option>1</option>
  298.      <option>2</option>
  299.      <option>3</option>
  300.      <option>4</option>
  301.      <option>5</option>
  302.      <option>6</option>
  303.      <option>7</option>
  304.      <option>8</option>
  305.      <option>9</option>
  306.      <option>10</option>
  307.     </select> </td>
  308.   </tr>
  309.   <tr>
  310.    <td width="43"><br> </td>
  311.    <td width="250"><b><font color="#ffffff">*</font> <font
  312. face="Arial, Helvetica"> <font size="2">How did you discover the Roxbury website?</font></font></b></td>
  313.    <td colspan="2" width="164"> <input type="text" size="20"
  314. name="howdiscoverroxnet"></td>
  315.   </tr>
  316.   <tr>
  317.     </table><br>
  318.      <table width="420" border="1" align="center" cellspacing="0" bordercolor="#000090"
  319. hspace="2" vspace="1">
  320.   <tr>
  321.    <td valign="top" width="42" bgcolor="#000090"
  322. bordercolor="#FFFFFF"> <b><font face="Arial"><font color="#ffffff"><font
  323. size="-1">CLICK BELOW</font> </font></font></b></td>
  324.    <td colspan=2 width="357" height="42" bgcolor="#000090"><b> <font
  325. face="Arial, Helvetica"><font color="#ffffff"> <font size="-1">CHOOSE FROM CURRENT
  326.     AND FORTHCOMING TITLES:</font> </font></font></b></td>
  327.   </tr>
  328.   <tr>
  329.    <td valign="top" width="42" bgcolor="#000090"
  330. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="al3">
  331.     <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
  332. size="-1">&nbsp;Order</font></font></font></b></td>
  333.    <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
  334.     <a
  335. href="active3.html">THE ACTIVE LEARNER: SUCCESSFUL STUDY STRATEGIES, 3rd ed.</a>
  336.     </font></font></b></td>
  337.   </tr>
  338.   <tr>
  339.    <td valign="top" width="42" bgcolor="#000090"
  340. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="dcj2">
  341.     <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
  342. size="-1">Order</font></font></font></b></td>
  343.    <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
  344.     <a
  345. href="roxdictionary2.html">THE AMERICAN DICTIONARY OF CRIMINAL JUSTICE: KEY TERMS
  346.     AND MAJOR COURT CASES, 2nd ed.</a> </font></font></b></td>
  347.   </tr>
  348.   <tr>
  349.    <td valign="top" width="42" bgcolor="#000090"
  350. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="dcj3">
  351.     <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
  352. size="-1">Order</font></font></font></b></td>
  353.    <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font
  354. color="#009900"> <font size="+1">*</font></font></font></b><b><font
  355. face="Arial, Helvetica"> <font size="-1"> <a href="dictionary3.html">THE AMERICAN
  356.     DICTIONARY OF CRIMINAL JUSTICE: KEY TERMS AND MAJOR COURT CASES, 3rd ed.</a>
  357.     <br>
  358.     </font></font></b><b><font face="Arial, Helvetica"><font
  359. color="#009900"> <font size="-1">available: Fall 2004</font></font></font></b><br>
  360.    </td>
  361.   </tr>
  362.   <tr>
  363.    <td valign="top" width="42" bgcolor="#000090"
  364. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="ad4">
  365.     <br> <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
  366. size="-1">Order</font></font></font></b></td>
  367.    <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
  368.     <a
  369. href="amerdrug4.html">THE AMERICAN DRUG SCENE: AN ANTHOLOGY, 4th ed.</a> </font></font></b><br>
  370.    </td>
  371.   </tr>
  372.   <tr>
  373.    <td valign="top" width="42" bgcolor="#000090"
  374. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="am"> <br> <b>
  375.     <font face="Arial, Helvetica"><font color="#ffffff"> <font
  376. size="-1">Order</font></font></font></b></td>
  377.    <td colspan=2 width="357"><b><font face="Arial, Helvetica"><font size="-1">
  378.     <a
  379. href="americanlegal.html">THE AMERICAN LEGAL SYSTEM: FOUNDATIONS, PROCESSES,
  380.     AND NORMS, 1st ed.</a> </font></font></b><br> </td>
  381.   </tr>
  382.     <tr>
  383.       <td valign="top" width="44" bgcolor="#000090"
  384. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="amsg"><br>
  385.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  386. size="-1">Order</font></font></font></b></td>
  387.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  388. href="americanlegal.html">STUDENT STUDY GUIDE FOR THE AMERICAN LEGAL SYSTEM:
  389.  FOUNDATIONS, PROCESSES, AND NORMS, 1st ed.</a> </font></font></b><br>
  390.       </td>
  391.      </tr>
  392.    <tr>
  393.       <td valign="top" width="44" bgcolor="#000090"
  394. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="ab2"><br>
  395.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  396. size="-1">Order</font></font></font></b></td>
  397.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  398. href="answer2.html">THE ANSWER book: A REFERENCE MANUAL FOR OFFICE PERSONNEL,
  399.  2nd ed.</a> </font></font></b></td>
  400.      </tr>
  401.    <tr>
  402.       <td valign="top" width="44" bgcolor="#000090"
  403. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection"
  404. value="abwbk"><br>
  405.    <b><font face="Arial, Helvetica"><font color="#ffffff"> <font
  406. size="-1">Order</font></font></font></b></td>
  407.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  408. href="answer2work.html">STUDENT WORKbook FOR THE ANSWER book, 2nd ed.</a>
  409.     </font></font></b></td>
  410.      </tr>
  411.    <tr>
  412.       <td valign="top" width="44" bgcolor="#000090"
  413. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="acc"><br>
  414.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  415. size="-1">Order</font></font></font></b></td>
  416.    <td width="357"><b><font face="Arial, Helvetica"><font
  417. color="#009900">     <font size="+1">*</font></font><font size="-1">
  418.     <a href="apollo.html">APOLLO, CHALLENGER, COLUMBIA: THE DECLINE OF
  419. THE SPACE PROGRAM (A STUDY IN ORGANIZATIONAL COMMUNICATION), 1st ed.</a>
  420.     </font></font></b><br>
  421.       <b><font face="Arial, Helvetica"><font color="#009900"> <font
  422. size="-1">available: Fall 2004</font></font></font></b></td>
  423.      </tr>
  424.    <tr>
  425.       <td valign="top" width="44" bgcolor="#000090"
  426. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="bi"><br>
  427.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  428. size="-1">Order</font></font></font></b></td>
  429.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  430. href="biologycrime.html">BIOLOGY AND CRIME, 1st ed.</a> </font></font></b></td>
  431.      </tr>
  432.    <tr>
  433.       <td valign="top" width="44" bgcolor="#000090"
  434. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="bc5"><br>
  435.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  436. size="-1">Order</font></font></font></b></td>
  437.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  438. href="bizcomm.html">BUSINESS COMMUNICATION: CONCEPTS AND APPLICATIONS IN
  439.  AN ELECTRONIC AGE, 5th ed.</a> </font></font></b></td>
  440.      </tr>
  441.       <td valign="top" width="44" bgcolor="#000090"
  442. bordercolor="#FFFFFF"> <input type="checkbox" NAME="book" ID="Book Selection" value="wc2"><br>
  443.       <b> <font face="Arial, Helvetica"><font color="#ffffff"> <font
  444. size="-1">Order</font></font></font></b></td>
  445.    <td width="357"><b><font face="Arial, Helvetica"><font size="-1"> <a
  446. href="writingcycle2.html">THE WRITING CYCLE: A FUNDAMENTAL TEXT FOR BEGINNING
  447.  AND INTERMEDIATE WRITERS, 2nd ed.</a> </font></font></b></td>
  448.      </tr>
  449.   <tr>
  450.    <td COLSPAN="2" ALIGN="center"><input TYPE="submit"> <input TYPE="reset"></td>
  451.   </tr>
  452.  </table>
  453. <p ALIGN="center"><font COLOR="#ff0000">*</font> Indicates a required field</p>
  454. </form>
  455. </body>
  456. </html>
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

That's strange, the javascript shouldn't affect the HTTP at all. Are you sure, when you added the script, that you didn't remove any hidden fields that might have been in the form? Some mail processors use a hidden field in the HTML to hold the from and subject lines. I, personaly, think that's a terrible idea, since it leaves your mailproc open to use by a spoofer... but nevertheless...

Do you have access to the Perl file? If so, see if you can backtrack the logic and see where it's supposed to be getting the header and subject line from.

.c
  • plumloopy
  • Newbie
  • Newbie
  • plumloopy
  • Posts: 5

Post 3+ Months Ago

Here's the perl code if import:

Code: [ Select ]


sub send_mail {
  # Localize variables used in this subroutine.              #
  local($print_config,$key,$sort_order,$sorted_field,$env_report);

  # Open The Mail Program
  open(MAIL,"|$mailprog");

  print MAIL "To: $Config{'recipient'}\n";
  print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

  # Check for Message Subject
  if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  else          { print MAIL "Subject: WWW Form Submission\n\n" }

  print MAIL "Below is the result of your feedback form. It was submitted by\n";
  print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  print MAIL "-" x 75 . "\n\n";

  if (@Print_Config) {
    foreach $print_config (@Print_Config) {
      if ($Config{$print_config}) {
        print MAIL "$print_config: $Config{$print_config}\n\n";
      }
    }
  }
  1. sub send_mail {
  2.   # Localize variables used in this subroutine.              #
  3.   local($print_config,$key,$sort_order,$sorted_field,$env_report);
  4.   # Open The Mail Program
  5.   open(MAIL,"|$mailprog");
  6.   print MAIL "To: $Config{'recipient'}\n";
  7.   print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
  8.   # Check for Message Subject
  9.   if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  10.   else          { print MAIL "Subject: WWW Form Submission\n\n" }
  11.   print MAIL "Below is the result of your feedback form. It was submitted by\n";
  12.   print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  13.   print MAIL "-" x 75 . "\n\n";
  14.   if (@Print_Config) {
  15.     foreach $print_config (@Print_Config) {
  16.       if ($Config{$print_config}) {
  17.         print MAIL "$print_config: $Config{$print_config}\n\n";
  18.       }
  19.     }
  20.   }


This part works:

Code: [ Select ]


  print MAIL "To: $Config{'recipient'}\n";
  print MAIL "From: $Config{'email'} ($Config{'realname'})\n";

  # Check for Message Subject
  if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  else          { print MAIL "Subject: WWW Form Submission\n\n" }
  1.   print MAIL "To: $Config{'recipient'}\n";
  2.   print MAIL "From: $Config{'email'} ($Config{'realname'})\n";
  3.   # Check for Message Subject
  4.   if ($Config{'subject'}) { print MAIL "Subject: $Config{'subject'}\n\n" }
  5.   else          { print MAIL "Subject: WWW Form Submission\n\n" }



But this part apparently doesn't:

Code: [ Select ]
  print MAIL "Below is the result of your feedback form. It was submitted by\n";
  print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  print MAIL "-" x 75 . "\n\n";

  if (@Print_Config) {
    foreach $print_config (@Print_Config) {
      if ($Config{$print_config}) {
        print MAIL "$print_config: $Config{$print_config}\n\n";
      }
    }
  }
  1.   print MAIL "Below is the result of your feedback form. It was submitted by\n";
  2.   print MAIL "$Config{'realname'} ($Config{'email'}) on $date\n";
  3.   print MAIL "-" x 75 . "\n\n";
  4.   if (@Print_Config) {
  5.     foreach $print_config (@Print_Config) {
  6.       if ($Config{$print_config}) {
  7.         print MAIL "$print_config: $Config{$print_config}\n\n";
  8.       }
  9.     }
  10.   }


I need that display of the name and email, because the FROM for most email programs won't display the email address also when printed.


Thanks!

Chris
  • Carnix
  • Guru
  • Guru
  • User avatar
  • Posts: 1098

Post 3+ Months Ago

What is $Config{'subject'}? That looks like a hash array, but I don't see it being populated anywhere. Is there any more to this Perl? Maybe a use statement that imports another module perhaps (would be at the top, probably just below the shebang line.

Anyway, the value of "subject" and "realname" are not defined anywhere in your HTML file. Try adding a hidden field named "subject" with a value of whatever you want your email subject to be. Then, change the Name field name to "realname" (change it in the HTML and in the JavaScript array).

See if that works.
.c

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 123 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.