Can anyone tell me why I keep getting this error when I try to open this page in Internet Explorer. It is an Intranet, so I can't actually give the site to view, but here is the code. The error keeps referring to line 20, I have looked through for the last 2 days and can not figure it out, any help would greatly be apprectiated.

<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)

{
  if (theForm.Last Name.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.Last Name.focus();
    return (false);
  }

  if (theForm.First Name.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.First Name.focus();
    return (false);
  }

  if (theForm.Course.value == "")
  {
    alert("Please enter a value for the \"Course\" field.");
    theForm.Course.focus();
    return (false);
  }

  if (theForm.Vendor.selectedIndex < 0)
  {
    alert("Please select one of the \"Vendor\" options.");
    theForm.Vendor.focus();
    return (false);
  }

  if (theForm.Start Date.value == "")
  {
    alert("Please enter a value for the \"Date\" field.");
    theForm.Start Date.focus();
    return (false);
  }

  if (theForm.Start Date.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Date\" field.");
    theForm.Start Date.focus();
    return (false);
  }

  if (theForm.End Date.value == "")
  {
    alert("Please enter a value for the \"End Date\" field.");
    theForm.End Date.focus();
    return (false);
  }

  if (theForm.End Date.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"End Date\" field.");
    theForm.End Date.focus();
    return (false);
  }

  if (theForm.Total Hours.value == "")
  {
    alert("Please enter a value for the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Total Hours.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  if (theForm.Cost of Class.value == "")
  {
    alert("Please enter a value for the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Cost of Class.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }
  return (true);
}
//--></script>

David
Shortly, I will firstly recomend to you not to use names of variables as follow

if (theForm.Last Name.value == "")

space between words which join for the name of variables are not good.

Secondly please can you provide full code for this script including html, it will help a lot to see it and understand what is going on.

Thanks

David
Shortly, I will firstly recomend to you not to use names of variables as follow

    if (theForm.[B]Last Name[/B].value == "")

space between words which join for the name of variables are not good.

Secondly please can you provide full code for this script including html, it will help a lot to see it and understand what is going on.

Thanks

Here it is, thanks again.

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
</head>

<body>
<p align="center">
<font face="Arial" size="5" color="#FF0000">Insert your Training Information Here</font></p>
<p align="center">
<font face="Arial">Please insert the training that you have 
completed in the fields below.&nbsp; If you need to look up your training 
records please go to this page.</font></p>
<p align="center">
<font face="Arial" color="#FF0000"><a href="results.asp">Training Report</a></font></p>
<script Language="JavaScript" Type="text/javascript"><!--
function FrontPage_Form1_Validator(theForm)

{
  if (theForm.Last Name.value == "")
  {
    alert("Please enter a value for the \"Last Name\" field.");
    theForm.Last Name.focus();
    return (false);
  }

  if (theForm.First Name.value == "")
  {
    alert("Please enter a value for the \"First Name\" field.");
    theForm.First Name.focus();
    return (false);
  }

  if (theForm.Course.value == "")
  {
    alert("Please enter a value for the \"Course\" field.");
    theForm.Course.focus();
    return (false);
  }

  if (theForm.Vendor.selectedIndex < 0)
  {
    alert("Please select one of the \"Vendor\" options.");
    theForm.Vendor.focus();
    return (false);
  }

  if (theForm.Start Date.value == "")
  {
    alert("Please enter a value for the \"Date\" field.");
    theForm.Start Date.focus();
    return (false);
  }

  if (theForm.Start Date.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"Date\" field.");
    theForm.Start Date.focus();
    return (false);
  }

  if (theForm.End Date.value == "")
  {
    alert("Please enter a value for the \"End Date\" field.");
    theForm.End Date.focus();
    return (false);
  }

  if (theForm.End Date.value.length > 10)
  {
    alert("Please enter at most 10 characters in the \"End Date\" field.");
    theForm.End Date.focus();
    return (false);
  }

  if (theForm.Total Hours.value == "")
  {
    alert("Please enter a value for the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Total Hours.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Total Hours\" field.");
    theForm.Total Hours.focus();
    return (false);
  }

  if (theForm.Cost of Class.value == "")
  {
    alert("Please enter a value for the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }

  var checkOK = "0123456789-.,";
  var checkStr = theForm.Cost of Class.value;
  var allValid = true;
  var validGroups = true;
  var decPoints = 0;
  var allNum = "";
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
        break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }
    if (ch == ".")
    {
      allNum += ".";
      decPoints++;
    }
    else if (ch == "," && decPoints != 0)
    {
      validGroups = false;
      break;
    }
    else if (ch != ",")
      allNum += ch;
  }
  if (!allValid)
  {
    alert("Please enter only digit characters in the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }

  if (decPoints > 1 || !validGroups)
  {
    alert("Please enter a valid number in the \"Cost of Class\" field.");
    theForm.Cost of Class.focus();
    return (false);
  }
  return (true);
}
//--></script>
<form method="POST" action="training.asp" webbot-action="--WEBBOT-SELF--">
    <input TYPE="hidden" NAME="VTI-GROUP" VALUE="0">
    <table border="0" width="100%" id="table1">
        <tr>
            <td><font face="Arial">Last Name:</font></td>
            <td width="580">
            <font face="Arial">
            <input type="text" name="Last Name" size="20" tabindex="1"></font></td>
        </tr>
        <tr>
            <td><font face="Arial">First Name:</font></td>
            <td width="580">
            <input type="text" name="First Name" size="20" tabindex="2"></td>
        </tr>
        <tr>
            <td><font face="Arial">Course:</font></td>
            <td width="580">
            <input type="text" name="Course" size="60" tabindex="3"></td>
        </tr>
        <tr>
            <td><font face="Arial">Vendor:</font></td>
            <td width="580">
            <span style="background-color: #EBEBDA">
            <select size="1" name="Vendor" tabindex="4" style="font-family: Arial">
            <option value="Accounts Payable">Accounts Payable</option>
            <option value="AMS">AMS</option>
            <option value="Cisco">Cisco</option>
            <option value="Cognos">Cognos</option>
            <option value="Concerto">Concerto</option>
            <option value="Global Knowledge">Global Knowledge</option>
            <option value="Harvard On-Line">Harvard On-Line</option>
            <option value="Human Factor">Human Factor</option>
            <option value="IBM">IBM</option>
            <option value="Learning Tree">Learning Tree</option>
            <option value="Microsoft E-Learning">Microsoft E-Learning</option>
            <option value="NetG">NetG</option>
            <option value="New Horizons">New Horizons</option>
            <option value="Oracle">Oracle</option>
            <option value="Red Dot">Red Dot</option>
            <option value="Skills on Demand">Skills on Demand</option>
            <option value="SolarTech">SolarTech</option>
            <option value="Stevens Institute">Stevens Institute</option>
            <option value="Sun">Sun</option>
            <option value="VZW">VZW</option>
            </select></span></td>
        </tr>
        <tr>
            <td><font face="Arial">Type of Training:</font></td>
            <td width="580">
            <span style="background-color: #EBEBDA">
            <select size="1" name="Type of Training" tabindex="5" style="font-family: Arial">
            <option value="Employee">Employee</option>
            <option value="Management">Management</option>
            <option value="Technical">Technical</option>
            </select></span></td>
        </tr>
        <tr>
            <td><font face="Arial">Start Date:</font></td>
            <td width="580">
            <input type="text" name="Start Date" size="10" tabindex="6" maxlength="10"> (Ex: 
            mm/dd/year)</td>
        </tr>
        <tr>
            <td><font face="Arial">End Date:</font></td>
            <td width="580">
            <input type="text" name="End Date" size="10" tabindex="7" maxlength="10"> (Ex: 
            mm/dd/year)</td>
        </tr>
        <tr>
            <td><font face="Arial">Total Hours:</font></td>
            <td width="580">
            <input type="text" name="Total Hours" size="5" tabindex="8"></td>
        </tr>
        <tr>
            <td><font face="Arial">Cost of Class</font></td>
            <td width="580">
            <input type="text" name="Cost of Class" size="10" tabindex="11"></td>
        </tr>
        <tr>
            <td><font face="Arial">Expense:</font></td>
            <td width="580">
            <input type="text" name="Expense" size="10" tabindex="12"></td>
        </tr>
        <tr>
            <td><font face="Arial">Comments:</font></td>
            <td width="580">
            <textarea rows="6" name="Comments" cols="50" tabindex="13"></textarea></td>
        </tr>
    </table>
    <p align="center"><br>
    <input type="submit" value="Submit" name="Submit" tabindex="14"><input type="reset" value="Reset" name="B2"></p>
</form>

</body>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.