[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 228
  • Last Modified:

form validation trouble

Here is my javascript:

<script language="JavaScript">
<!--
function formCheck2(formobj){
      // Enter name of mandatory fields
      var fieldRequired = Array("sname","email","saddress1","scity","sstate","szip","saffiliation","essay","agreetorules");
      // Enter field description to appear in the dialog box
      var fieldDescription = Array("Name of Individual Submitter","Email Address","Address 1","City","State","Zip","Affiliation to Site","Essay","You must check the box stating that you have read the Official Rules.");
      // dialog message
      var alertMsg = "Please complete the following fields:\n";
      
      var l_Msg = alertMsg.length;
      
      for (var i = 0; i < fieldRequired.length; i++){
            var obj = formobj.elements[fieldRequired[i]];
            if (obj){
                  switch(obj.type){
                  case "select-one":
                        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "select-multiple":
                        if (obj.selectedIndex == -1){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "text":
                  case "textarea":
                        if (obj.value == "" || obj.value == null){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  default:
                  }
                  if (obj.type == undefined){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                              if (obj[j].checked){
                                    blnchecked = true;
                              }
                        }
                        if (!blnchecked){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                  }
            }
      }

      if (alertMsg.length == l_Msg){
            return true;
      }else{
            alert(alertMsg);
            return false;
      }
}
// -->
</script>

The "agreetorules" field is a checkbox and the javascript doesn't seem to include this when it checks the form.  I am able to submit the form without it being checked.  Any ideas?
0
toddynho
Asked:
toddynho
  • 6
  • 3
1 Solution
 
archrajanCommented:
if (obj.type == undefined)
shud be
 if (obj.type == checkbox)
0
 
archrajanCommented:
can u post ur html from the view source, thats easier to debug
0
 
toddynhoAuthor Commented:
when I do this the regular text fields don't validate... even though they are defined in the JS right above textarea...
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
archrajanCommented:
post ur html view source so that we can have a look
0
 
toddynhoAuthor Commented:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Take Back Essay Contest</title>
<script language="JavaScript">
<!--
function formCheck2(formobj){
      // Enter name of mandatory fields
      var fieldRequired = Array("sname","email","saddress1","scity","sstate","szip","saffiliation","essay","agreetorules");
      // Enter field description to appear in the dialog box
      var fieldDescription = Array("Name of Individual Submitter","Email Address","Address 1","City","State","Zip","Affiliation to Site","Essay","You must check the box stating that you have read the Official Rules.");
      // dialog message
      var alertMsg = "Please complete the following fields:\n";
      
      var l_Msg = alertMsg.length;
      
      for (var i = 0; i < fieldRequired.length; i++){
            var obj = formobj.elements[fieldRequired[i]];
            if (obj){
                  switch(obj.type){
                  case "select-one":
                        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "select-multiple":
                        if (obj.selectedIndex == -1){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "text":
                  case "textarea":
                        if (obj.value == "" || obj.value == null){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  default:
                  }
                  if (obj.type == undefined){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                              if (obj[j].checked){
                                    blnchecked = true;
                              }
                        }
                        if (!blnchecked){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                  }
                  if (obj.type == checkbox){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                              if (obj[j].checked){
                                    blnchecked = true;
                              }
                        }
                        if (!blnchecked){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                  }
            }
      }

      if (alertMsg.length == l_Msg){
            return true;
      }else{
            alert(alertMsg);
            return false;
      }
}
// -->
</script>
<link href="gdmessay.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
      background-color: #FFFFFF;
}
.style23 {
      font-size: 10px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-weight: bold;
}
.style43 {
      color: #000000;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 18px;
      font-weight: bold;
}
.style44 {font-size: 10px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>

<body>
<table width="780" height="198" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="780" height="198" align="left" valign="top"><table width="780" height="94" border="0" cellpadding="0" cellspacing="0">
      <tr align="left" valign="top">
        <td height="94"><img src="FAQs_01.gif" width="252" height="94" border="0" usemap="#Map"></td>
        <td><img src="FAQs_02.gif" width="252" height="94"></td>
        <td><img src="FAQs_03.gif" width="276" height="94"></td>
      </tr>
    </table>    
      <table width="780" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td height="22"><img src="transparent.gif" width="90" height="25"></td>
          <td><p align="center"><img src="transparent.gif" width="600" height="5" align="top"><span class="style44"><strong><br>
          </strong></span></p></td>
          <td><img src="transparent.gif" width="90" height="25"></td>
        </tr>
      </table>
      <table width="780" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td height="23"><img src="transparent.gif" width="90" height="20"></td>
          <td><p align="left"><img src="transparent.gif" width="600" height="20"></p>
            <p align="center"><span class="style43">
<div id="container">
 
        <form method="post" name="form1" onsubmit="return formCheck2(this);">
      <fieldset>
    <legend>Individual Submission</legend>
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                   
                  <td>Name of Individual Submitter:*</td>
                    <td><input type="text" name="sname" value="" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>Email Address:*</td>
                    <td><input type="text" name="email" value="" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>Address 1:*</td>
                    <td><input type="text" name="saddress1" value="" size="32"></td>
                  </tr>
                  <tr>
                    <td>Address 2:</td>
                    <td><input type="text" name="saddress2" value="" size="32"></td>
                  </tr>
                  <tr>
                   
                  <td>City:*</td>
                    <td><input type="text" name="scity" value="" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>State:*</td>
                    <td><input type="text" name="sstate" value="" size="12"></td>
                  </tr>
                  <tr>
                   
                  <td>Zip:*</td>
                    <td><input type="text" name="szip" value="" size="8"></td>
                  </tr>
                  <tr>
                    <td valign="top">Phone #:</td>
                    <td><input type="text" name="sphone1" value="" size="15">
                      home<br /> <input type="text" name="sphone2" value="" size="15">
                      work<br /> <input type="text" name="sphone3" value="" size="15">
                      cell</td>
                  </tr>
                  <tr>
                    <td>Affiliation to Site:</td>
                    <td> <select name="saffiliation">
                        <option value="owner" >Owner</option>
                        <option value="officer" >Officer</option>
                        <option value="director" >Director</option>
                        <option value="resident" >Resident</option>
                        <option value="employee" >Employee</option>
                        <option value="other" >Other</option>
                      </select> </td>
                  </tr>
                  <tr>
                    <td valign="top">If Other, please explain</td>
                    <td><input type="text" name="saffiliation2" value="" size="22"></td>
                  </tr>
                  <tr>
                   
                  <td colspan="2">Essay: (250 words or less) *<br /> <textarea name="essay" cols="60" rows="15"></textarea></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input type="checkbox" name="agreetorules" value="yes">
                      I have read the Complete <a href="officialrules.htm" target="_blank">Official
                      Rules </a></td>
                  </tr>
                  <tr align="right">
                    <td colspan="2" style="border-top: 1px solid #666; background-color: #e7e7e7;">
                      <input type="submit" name="MM_insert" value="Submit!" onclick="return checkForm(this.form)"> </td>
                  </tr>
                </table>
    </fieldset>
        <input type="hidden" name="status" value="unjudged">
    <input type="hidden" name="nameofsite" value="test">
    <input type="hidden" name="ownership" value="individual">
    <input type="hidden" name="state" value="colorado">
    <input type="hidden" name="address1" value="test">
    <input type="hidden" name="address2" value="test">
    <input type="hidden" name="city" value="test">
    <input type="hidden" name="zip" value="test">
    <input type="hidden" name="metropolitanarea" value="Chicago - IL">
    <input type="hidden" name="typeofsite" value="Recreational Site">
    <input type="hidden" name="typeother" value="">
    <input type="hidden" name="sitesize" value="Less Than 1 Acre">
    <input type="hidden" name="phone" value="test">
    <input type="hidden" name="date" value="2005-04-11 16:04:47">
  </form>
</div>
</span> <span class="style23"><br>
          </span></p></td>
          <td><img src="transparent.gif" width="90" height="20"></td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<map name="Map">
  <area shape="rect" coords="82,6,218,81" href="index.htm" target="_self">
</map>
</body>
</html>
0
 
archrajanCommented:
it shud be like this
  if (obj.type == "checkbox")
 pls put the quotes around checkbox
0
 
toddynhoAuthor Commented:
here's the current html, now even though the box is checked it asks you to check the box...


<?php

$nameofsite = $_POST['nameofsite'];
$ownership = $_POST['ownership'];
$state = $_POST['state'];
$address1 = $_POST['address1'];
$address2 = $_POST['address2'];
$city = $_POST['city'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$metropolitanarea = $_POST['metropolitanarea'];
$typeofsite = $_POST['typeofsite'];
$typeother = $_POST['typeother'];
$sitesize = $_POST['sitesize'];

//Connection statement
require_once('Connections/gdmDBconnect.php');

//Aditional Functions
require_once('includes/functions.inc.php');

//load the tNG classes
require_once('tNG/KT_tNG.inc.php');

//start trigger UniVal1
//remove this line if you want to edit  the code by hand
function KT_TriggerBEFORE_UniVal1(&$tNG) {
  $colNames = Array(('ownership'),('nameofsite'),('state'),('address1'),('address2'),('city'),('zip'),('phone'),('sname'),('jsrrep'),('saddress1'),('saddress2'),('scity'),('sstate'),('szip'),('sphone1'),('sphone2'),('sphone3'),('saffiliation'),('saffiliation2'),('status'),('essay'),('email'));
  $required = Array((false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false),(false));
  $regExp = Array(('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'),('(.|\n)*'));
  $labels = Array(('The value of the field \'Ownership\' is incorrect!'),('Please enter the name of the site.'),('Please select a state.'),('Please enter the address of the site.'),('The value of the field \'Address2\' is incorrect!'),('Please enter the city of the site.'),('Please enter the zip code of the site.'),('The value of the field \'Phone\' is incorrect!'),('The value of the field \'Sname\' is incorrect!'),('The value of the field \'Jsrrep\' is incorrect!'),('The value of the field \'Saddress1\' is incorrect!'),('The value of the field \'Saddress2\' is incorrect!'),('The value of the field \'Scity\' is incorrect!'),('The value of the field \'Sstate\' is incorrect!'),('The value of the field \'Szip\' is incorrect!'),('The value of the field \'Sphone1\' is incorrect!'),('The value of the field \'Sphone2\' is incorrect!'),('The value of the field \'Sphone3\' is incorrect!'),('The value of the field \'Saffiliation\' is incorrect!'),('The value of the field \'Saffiliation2\' is incorrect!'),('The value of the field \'Status\' is incorrect!'),('Please enter your essay.'),('The value of the field \'Email\' is incorrect!'));
  $uniVal = new UniValValidator($labels, $required, $regExp, $tNG->nameToValue, $colNames);
  if (($err = $uniVal->validateFields()) != "") {
    $tNG->setError(-1,$err);
  }
}
//end trigger UniVal1

//start trigger Email1
//remove this line if you want to edit  the code by hand
function KT_TriggerAFTER_Email1(&$tNG) {
  $to = '' . $tNG->nameToValue['email'] . '';
  $subject = 'Essay Entry Received! [Mosquito Magnet Contest]';
  $message = '-------------------------------------------------------------------------------
Name of site: ' . $tNG->nameToValue['nameofsite'] . '

This email is to confirm that your essay entry for the Mosquito Magnet Contest has been received!

Thank you for entering!

--------------------------------------------------------------------------------------
END';
  $extraHeader = 'From: admin@mosquitomagnetcontest.com' . "\n";
  if (!@mail($to,$subject,$message,$extraHeader)) {
    $tNG->setError(-1,'Error sending email, please insert a valid email address to enter the contest!');
  }
}
//end trigger Email1

//start trigger RollBack1
//remove this line if you want to edit  the code by hand
function KT_TriggerERROR_RollBack1(&$tNG) {
  $keyQuote = $tNG->type2quote[NUMERIC_TYPE];
  $sql = "delete from " . $tNG->getTable() . " where ID = " . $keyQuote . $tNG->getRecordId() . $keyQuote;
  $tNG->connection->Execute($sql);
}
//end trigger RollBack1

//start trigger Redirect1
//remove this line if you want to edit  the code by hand
function KT_TriggerAFTER_Redirect1(&$tNG) {
  global $HTTP_SERVER_VARS;
  $insertGoTo = "success.php";
  KT_redir($insertGoTo);
}
//end trigger Redirect1

// make an instance of the transaction object
$essayInsert = new KT_tNG();
// register to a connection
$essayInsert->setConnection($gdmDBconnect);

// register the UniVal1 trigger
$essayInsert->registerTrigger(BEFORE,'KT_TriggerBEFORE_UniVal1',1);

// register the Email1 trigger
$essayInsert->registerTrigger(AFTER,'KT_TriggerAFTER_Email1',1);

// register the RollBack1 trigger
$essayInsert->registerTrigger(ERROR,'KT_TriggerERROR_RollBack1',2);

// register the Redirect1 trigger
$essayInsert->registerTrigger(AFTER,'KT_TriggerAFTER_Redirect1',2);

//set the STARTER condition
$essayInsert->registerTrigger(STARTER,'KT_TriggerSTARTER_Default',1,(isset($HTTP_POST_VARS['MM_insert']) ? $HTTP_POST_VARS['MM_insert'] : null));
$essayInsert->registerTrigger(ERROR,"KT_TriggerERROR_ProduceFakeRs",1);
// set the autogeneration information
$essayInsert->setTransactionType(INSERT_TYPE);
$essayInsert->setTable('entries');
$essayInsert->setColumnsName(Array(('ownership'),('nameofsite'),('state'),('address1'),('address2'),('city'),('zip'),('phone'),('sname'),('jsrrep'),('saddress1'),('saddress2'),('scity'),('sstate'),('szip'),('sphone1'),('sphone2'),('sphone3'),('saffiliation'),('saffiliation2'),('status'),('essay'),('email'),('date'),('greaterarea'),('typeofsite'),('typeother'),('sitesize')));
$essayInsert->setColumnsType(Array((STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(DATA_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE),(STRING_TYPE)));
$essayInsert->setColumnsValue(Array(((isset($HTTP_POST_VARS['ownership']) ? $HTTP_POST_VARS['ownership'] : null)),((isset($HTTP_POST_VARS['nameofsite']) ? $HTTP_POST_VARS['nameofsite'] : null)),((isset($HTTP_POST_VARS['state']) ? $HTTP_POST_VARS['state'] : null)),((isset($HTTP_POST_VARS['address1']) ? $HTTP_POST_VARS['address1'] : null)),((isset($HTTP_POST_VARS['address2']) ? $HTTP_POST_VARS['address2'] : null)),((isset($HTTP_POST_VARS['city']) ? $HTTP_POST_VARS['city'] : null)),((isset($HTTP_POST_VARS['zip']) ? $HTTP_POST_VARS['zip'] : null)),((isset($HTTP_POST_VARS['phone']) ? $HTTP_POST_VARS['phone'] : null)),((isset($HTTP_POST_VARS['sname']) ? $HTTP_POST_VARS['sname'] : null)),((isset($HTTP_POST_VARS['jsrrep']) ? $HTTP_POST_VARS['jsrrep'] : null)),((isset($HTTP_POST_VARS['saddress1']) ? $HTTP_POST_VARS['saddress1'] : null)),((isset($HTTP_POST_VARS['saddress2']) ? $HTTP_POST_VARS['saddress2'] : null)),((isset($HTTP_POST_VARS['scity']) ? $HTTP_POST_VARS['scity'] : null)),((isset($HTTP_POST_VARS['sstate']) ? $HTTP_POST_VARS['sstate'] : null)),((isset($HTTP_POST_VARS['szip']) ? $HTTP_POST_VARS['szip'] : null)),((isset($HTTP_POST_VARS['sphone1']) ? $HTTP_POST_VARS['sphone1'] : null)),((isset($HTTP_POST_VARS['sphone2']) ? $HTTP_POST_VARS['sphone2'] : null)),((isset($HTTP_POST_VARS['sphone3']) ? $HTTP_POST_VARS['sphone3'] : null)),((isset($HTTP_POST_VARS['saffiliation']) ? $HTTP_POST_VARS['saffiliation'] : null)),((isset($HTTP_POST_VARS['saffiliation2']) ? $HTTP_POST_VARS['saffiliation2'] : null)),((isset($HTTP_POST_VARS['status']) ? $HTTP_POST_VARS['status'] : null)),((isset($HTTP_POST_VARS['essay']) ? $HTTP_POST_VARS['essay'] : null)),((isset($HTTP_POST_VARS['email']) ? $HTTP_POST_VARS['email'] : null)),((isset($HTTP_POST_VARS['date']) ? $HTTP_POST_VARS['date'] : null)),((isset($HTTP_POST_VARS['metropolitanarea']) ? $HTTP_POST_VARS['metropolitanarea'] : null)),((isset($HTTP_POST_VARS['typeofsite']) ? $HTTP_POST_VARS['typeofsite'] : null)),((isset($HTTP_POST_VARS['typeother']) ? $HTTP_POST_VARS['typeother'] : null)),((isset($HTTP_POST_VARS['sitesize']) ? $HTTP_POST_VARS['sitesize'] : null))));

// execute the transaction
$essayInsert->executeTransaction();

// default values for transaction essayInsert
if (!isset($KT_fakeRs)) {
  $KT_fakeRs = new fakeRecordSet();
  $KT_fakeRs->PrepareValue('ownership', "");
  $KT_fakeRs->PrepareValue('nameofsite', "");
  $KT_fakeRs->PrepareValue('state', "");
  $KT_fakeRs->PrepareValue('address1', "");
  $KT_fakeRs->PrepareValue('address2', "");
  $KT_fakeRs->PrepareValue('city', "");
  $KT_fakeRs->PrepareValue('zip', "");
  $KT_fakeRs->PrepareValue('phone', "");
  $KT_fakeRs->PrepareValue('sname', "");
  $KT_fakeRs->PrepareValue('jsrrep', "");
  $KT_fakeRs->PrepareValue('saddress1', "");
  $KT_fakeRs->PrepareValue('saddress2', "");
  $KT_fakeRs->PrepareValue('scity', "");
  $KT_fakeRs->PrepareValue('sstate', "");
  $KT_fakeRs->PrepareValue('szip', "");
  $KT_fakeRs->PrepareValue('sphone1', "");
  $KT_fakeRs->PrepareValue('sphone2', "");
  $KT_fakeRs->PrepareValue('sphone3', "");
  $KT_fakeRs->PrepareValue('saffiliation', "");
  $KT_fakeRs->PrepareValue('saffiliation2', "");
  $KT_fakeRs->PrepareValue('status', "unjudged");
  $KT_fakeRs->PrepareValue('essay', "");
  $KT_fakeRs->PrepareValue('email', "");
  $KT_fakeRs->PrepareValue('date', "");
  $KT_fakeRs->PrepareValue('greaterarea', "");
  $KT_fakeRs->PrepareValue('typeofsite', "");
  $KT_fakeRs->PrepareValue('typeother', "");
  $KT_fakeRs->PrepareValue('sitesize', "");
}
// end default values for transaction essayInsert
 //PHP ADODB document - made with PHAkt 2.7.3?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Take Back Essay Contest</title>
<script language="JavaScript">
<!--
function formCheck2(formobj){
      // Enter name of mandatory fields
      var fieldRequired = Array("sname","email","saddress1","scity","sstate","szip","saffiliation","essay","agreetorules");
      // Enter field description to appear in the dialog box
      var fieldDescription = Array("Name of Individual Submitter","Email Address","Address 1","City","State","Zip","Affiliation to Site","Essay","You must check the box stating that you have read the Official Rules.");
      // dialog message
      var alertMsg = "Please complete the following fields:\n";
      
      var l_Msg = alertMsg.length;
      
      for (var i = 0; i < fieldRequired.length; i++){
            var obj = formobj.elements[fieldRequired[i]];
            if (obj){
                  switch(obj.type){
                  case "select-one":
                        if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "select-multiple":
                        if (obj.selectedIndex == -1){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  case "text":
                  case "textarea":
                        if (obj.value == "" || obj.value == null){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                        break;
                  default:
                  }
                  if (obj.type == "checkbox"){
                        var blnchecked = false;
                        for (var j = 0; j < obj.length; j++){
                              if (obj[j].checked){
                                    blnchecked = true;
                              }
                        }
                        if (!blnchecked){
                              alertMsg += " - " + fieldDescription[i] + "\n";
                        }
                  }
            }
      }

      if (alertMsg.length == l_Msg){
            return true;
      }else{
            alert(alertMsg);
            return false;
      }
}
// -->
</script>
<link href="gdmessay.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
body {
      margin-left: 0px;
      margin-top: 0px;
      margin-right: 0px;
      margin-bottom: 0px;
      background-color: #FFFFFF;
}
.style23 {
      font-size: 10px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-weight: bold;
}
.style43 {
      color: #000000;
      font-family: Verdana, Arial, Helvetica, sans-serif;
      font-size: 18px;
      font-weight: bold;
}
.style44 {font-size: 10px;
      font-family: Verdana, Arial, Helvetica, sans-serif;
}
-->
</style>
<script language="JavaScript" type="text/JavaScript">
<!--



function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-->
</script>
</head>

<body>
<table width="780" height="198" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="780" height="198" align="left" valign="top"><table width="780" height="94" border="0" cellpadding="0" cellspacing="0">
      <tr align="left" valign="top">
        <td height="94"><img src="FAQs_01.gif" width="252" height="94" border="0" usemap="#Map"></td>
        <td><img src="FAQs_02.gif" width="252" height="94"></td>
        <td><img src="FAQs_03.gif" width="276" height="94"></td>
      </tr>
    </table>    
      <table width="780" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td height="22"><img src="transparent.gif" width="90" height="25"></td>
          <td><p align="center"><img src="transparent.gif" width="600" height="5" align="top"><span class="style44"><a href="http://www.mosquitomagnet.com/sweepstakes/privacypolicy.html" target="_blank">Privacy Policy</a>&nbsp;&nbsp; <a href="http://www.mosquitomagnet.com" target="_blank">Copyright &copy; 2005 American Biophysics Corporation </a></span><span class="style44"><strong><br>
          </strong></span></p></td>
          <td><img src="transparent.gif" width="90" height="25"></td>
        </tr>
      </table>
      <table width="780" border="0" cellspacing="0" cellpadding="0">
        <tr align="left" valign="top">
          <td height="23"><img src="transparent.gif" width="90" height="20"></td>
          <td><p align="left"><img src="transparent.gif" width="600" height="20"></p>
            <p align="center"><span class="style43">
<div id="container">
<?php
if ($essayInsert->getErrorNo()) {
?>
<?php  
  echo $essayInsert->getErrorMsg();
?>
<?php
} // end Display Error
?>
 
    <?php if ( ($ownership == 'individual') ) { ?>
    <form method="post" name="form1" onsubmit="return formCheck2(this);">
      <fieldset>
    <legend>Individual Submission</legend>
                <table width="100%" border="0" cellspacing="0" cellpadding="5">
                  <tr>
                   
                  <td>Name of Individual Submitter:*</td>
                    <td><input type="text" name="sname" value="<?php echo htmlentities($KT_fakeRs->Fields('sname'))?>" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>Email Address:*</td>
                    <td><input type="text" name="email" value="<?php echo htmlentities($KT_fakeRs->Fields('email'))?>" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>Address 1:*</td>
                    <td><input type="text" name="saddress1" value="<?php echo htmlentities($KT_fakeRs->Fields('saddress1'))?>" size="32"></td>
                  </tr>
                  <tr>
                    <td>Address 2:</td>
                    <td><input type="text" name="saddress2" value="<?php echo htmlentities($KT_fakeRs->Fields('saddress2'))?>" size="32"></td>
                  </tr>
                  <tr>
                   
                  <td>City:*</td>
                    <td><input type="text" name="scity" value="<?php echo htmlentities($KT_fakeRs->Fields('scity'))?>" size="25"></td>
                  </tr>
                  <tr>
                   
                  <td>State:*</td>
                    <td><input type="text" name="sstate" value="<?php echo htmlentities($KT_fakeRs->Fields('sstate'))?>" size="12"></td>
                  </tr>
                  <tr>
                   
                  <td>Zip:*</td>
                    <td><input type="text" name="szip" value="<?php echo htmlentities($KT_fakeRs->Fields('szip'))?>" size="8"></td>
                  </tr>
                  <tr>
                    <td valign="top">Phone #:</td>
                    <td><input type="text" name="sphone1" value="<?php echo htmlentities($KT_fakeRs->Fields('sphone1'))?>" size="15">
                      home<br /> <input type="text" name="sphone2" value="<?php echo htmlentities($KT_fakeRs->Fields('sphone2'))?>" size="15">
                      work<br /> <input type="text" name="sphone3" value="<?php echo htmlentities($KT_fakeRs->Fields('sphone3'))?>" size="15">
                      cell</td>
                  </tr>
                  <tr>
                    <td>Affiliation to Site:</td>
                    <td> <select name="saffiliation">
                        <option value="owner" >Owner</option>
                        <option value="officer" >Officer</option>
                        <option value="director" >Director</option>
                        <option value="resident" >Resident</option>
                        <option value="employee" >Employee</option>
                        <option value="other" >Other</option>
                      </select> </td>
                  </tr>
                  <tr>
                    <td valign="top">If Other, please explain</td>
                    <td><input type="text" name="saffiliation2" value="<?php echo htmlentities($KT_fakeRs->Fields('saffiliation2'))?>" size="22"></td>
                  </tr>
                  <tr>
                   
                  <td colspan="2">Essay: (250 words or less) *<br /> <textarea name="essay" cols="60" rows="15"></textarea></td>
                  </tr>
                  <tr>
                    <td colspan="2"><input type="checkbox" name="agreetorules" value="yes">
                      I have read the Complete <a href="officialrules.htm" target="_blank">Official
                      Rules </a></td>
                  </tr>
                  <tr align="right">
                    <td colspan="2" style="border-top: 1px solid #666; background-color: #e7e7e7;">
                      <input type="submit" name="MM_insert" value="Submit!" onclick="return checkForm(this.form)"> </td>
                  </tr>
                </table>
    </fieldset>
    <?php } else if ( ($ownership == 'joint') ) { ?>
      <form method="post" name="form1" onsubmit="return formCheck3(this);">
    <fieldset>
    <legend>Joint Submission</legend>
    <table width="100%" border="0" cellspacing="0" cellpadding="5">
      <tr>
        <td>Names of Joint Submitters:</td>
        <td><input type="text" name="jsname" value="<?php echo htmlentities($KT_fakeRs->Fields('jsname'))?>" size="25"></td>
      </tr>
      <tr>
        <td >Name of Joint Submitter Representative:</td>
        <td><input type="text" name="jsrrep" value="<?php echo htmlentities($KT_fakeRs->Fields('jsrrep'))?>" size="32"></td>
      </tr>
      <tr>
        <td>Email address of Representative:</td>
        <td><input type="text" name="email2" value="<?php echo htmlentities($KT_fakeRs->Fields('email'))?>" size="25"></td>
      </tr>
      <tr>
        <td>Address 1:</td>
        <td><input type="text" name="jsaddress1" value="<?php echo htmlentities($KT_fakeRs->Fields('jsaddress1'))?>" size="32"></td>
      </tr>
      <tr>
        <td>Address 2:</td>
        <td><input type="text" name="jsaddress2" value="<?php echo htmlentities($KT_fakeRs->Fields('jsaddress2'))?>" size="32"></td>
      </tr>
      <tr>
        <td>City:</td>
        <td><input type="text" name="jscity" value="<?php echo htmlentities($KT_fakeRs->Fields('jscity'))?>" size="25"></td>
      </tr>
      <tr>
        <td>State:</td>
        <td><input type="text" name="jsstate" value="<?php echo htmlentities($KT_fakeRs->Fields('jsstate'))?>" size="12"></td>
      </tr>
      <tr>
        <td>Zip:</td>
        <td><input type="text" name="jszip" value="<?php echo htmlentities($KT_fakeRs->Fields('jszip'))?>" size="8"></td>
      </tr>
      <tr>
        <td valign="top">Phone #:</td>
        <td><input type="text" name="jsphone1" value="<?php echo htmlentities($KT_fakeRs->Fields('jsphone1'))?>" size="15">
          home<br /> <input type="text" name="jsphone2" value="<?php echo htmlentities($KT_fakeRs->Fields('jsphone2'))?>" size="15">
          work<br /> <input type="text" name="jsphone3" value="<?php echo htmlentities($KT_fakeRs->Fields('jsphone3'))?>" size="15">
          cell</td>
      </tr>
      <tr>
        <td>Affiliation to Site:</td>
        <td> <select name="jsaffiliation">
            <option value="owner" >Owner</option>
            <option value="officer" >Officer</option>
            <option value="director" >Director</option>
            <option value="resident" >Resident</option>
            <option value="employee" >Employee</option>
            <option value="other" >Other</option>
          </select> </td>
      </tr>
      <tr>
        <td valign="top">If Other, please explain</td>
        <td><input type="text" name="jsaffiliation2" value="<?php echo htmlentities($KT_fakeRs->Fields('jsaffiliation2'))?>" size="22"></td>
      </tr>
      <tr>
        <td colspan="2">Essay: (250 words or less)<br /> <textarea name="essay" cols="60" rows="15"></textarea></td>
      </tr>
        <tr>
                    <td colspan="2"><input type="checkbox" name="agreetorules" value="checkbox">
                      I have read the Complete <a href="officialrules.htm" target="_blank">Official
                      Rules </a></td>
                  </tr>
      <tr align="right">
        <td colspan="2" style="border-top: 1px solid #666; background-color: #e7e7e7;">
          <input type="submit" name="MM_insert" value="Submit!"> </td>
      </tr>
    </table>
    </fieldset>
    <?php } else { ?>
    Sorry, Sites owned by governmental/public units or entities are not eligible
    to enter or win the contest.
    <?php } // end if ?>
    <input type="hidden" name="status" value="<?php echo htmlentities($KT_fakeRs->Fields('status'))?>">
    <input type="hidden" name="nameofsite" value="<?php echo $nameofsite?>">
    <input type="hidden" name="ownership" value="<?php echo $ownership?>">
    <input type="hidden" name="state" value="<?php echo $state?>">
    <input type="hidden" name="address1" value="<?php echo $address1?>">
    <input type="hidden" name="address2" value="<?php echo $address2?>">
    <input type="hidden" name="city" value="<?php echo $city?>">
    <input type="hidden" name="zip" value="<?php echo $zip?>">
    <input type="hidden" name="metropolitanarea" value="<?php echo $metropolitanarea?>">
    <input type="hidden" name="typeofsite" value="<?php echo $typeofsite?>">
    <input type="hidden" name="typeother" value="<?php echo $typeother?>">
    <input type="hidden" name="sitesize" value="<?php echo $sitesize?>">
    <input type="hidden" name="phone" value="<?php echo $phone?>">
    <input type="hidden" name="date" value="<?php echo date("Y-m-d H:m:s")?>">
  </form>
</div>
<?php include("footer.php"); ?>
0
 
archrajanCommented:
FOR CHECKBOX: THIS IS JUST ENOUGH:
if (obj.type == "checkbox"){
                  
             
                         if (!obj.checked){
                       
                         
                 
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
               }
0
 
archrajanCommented:
UR UPDATED FUNCTION
<script language="JavaScript">
<!--
function formCheck2(formobj){
     // Enter name of mandatory fields
     var fieldRequired = Array("sname","email","saddress1","scity","sstate","szip","saffiliation","essay","agreetorules");
     // Enter field description to appear in the dialog box
     var fieldDescription = Array("Name of Individual Submitter","Email Address","Address 1","City","State","Zip","Affiliation to Site","Essay","You must check the box stating that you have read the Official Rules.");
     // dialog message
     var alertMsg = "Please complete the following fields:\n";
     
     var l_Msg = alertMsg.length;
     
     for (var i = 0; i < fieldRequired.length; i++){
          var obj = formobj.elements[fieldRequired[i]];
          if (obj){
               switch(obj.type){
               case "select-one":
                    if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                    break;
               case "select-multiple":
                    if (obj.selectedIndex == -1){
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                    break;
               case "text":
               case "textarea":
                    if (obj.value == "" || obj.value == null){
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
                    break;
               default:
               }
               if (obj.type == undefined){
                    var blnchecked = false;
                    for (var j = 0; j < obj.length; j++){
                         if (obj[j].checked){
                              blnchecked = true;
                         }
                    }
                    if (!blnchecked){
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
               }
               if (obj.type == "checkbox"){
                  
             
                         if (!obj.checked){
                       
                         
                 
                         alertMsg += " - " + fieldDescription[i] + "\n";
                    }
               }
          }
     }

     if (alertMsg.length == l_Msg){
          return true;
     }else{
          alert(alertMsg);
          return false;
     }
}
// -->
</script>
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now