Click to See Complete Forum and Search --> : error: object expected


rmsonger
07-16-2003, 08:48 AM
I have the dreaded 'object expected' popping up when clicking on the submit button. I have seen the code I am using in various permutations in several books and online here.

<script src="/js-lib/formLib.js" type="text/javascript">
<script>
<!--
// form validation
function validateForm ( form ) {

requiredText = new Array( "LastName", "HomePhone", "Address1", "City", "PostalCode", "HomePhone", "WorkPhone", "CityPU",
"PostalCodePU", "CityDlv", "PostalCodeDlv" );
requiredSelect = new Array( "State", "StatePU", "StateDlv", "StairsPU", "NoOfStairsPU", "CarryPU", "ElevatorPU",
"StairsDlv", "NoOfStairsDlv", "CarryDlv", "ElevatorDlv" );
requiredCheckBox = new Array( "chkAgree" );

return requiredTexts ( form, requiredText ) &&
requiredSelects ( form, requiredSelect ) &&
requiredCheckBoxes ( form, requiredCheckBox ) &&
checkProblems ();
}
//-->
</script>

In the body I have this line
<name="ShippingQuote" onSubmit="return validateForm( this )">

this is the line IE says is the problem. I have used it with a semicolon after the closing parenthsis and without. I have seen the code exampled both ways. Since I am a js novice, I am not sure about which is correct. Any ideas?

Khalid Ali
07-16-2003, 09:44 AM
if this line

<name="ShippingQuote" onSubmit="return validateForm( this )">

is correct code you have in your page then IE is right..

because name is not an html element

it should be like this'

<form name="ShippingQuote" onSubmit="return validateForm( this )">

rmsonger
07-16-2003, 10:20 AM
my mistake, I snipped the method and action properties before posting and took out the form tag when I did so. The <form> is in place.
here is the link to the page:
http://www.vintagetransport.com/quote.html
I know it has to be a typo kind of thing, I just don't see it. I wonder though. When I first completed the external file and the head script, I was getting the object expected error. I added a semi-colon to the onSubmit=function() and began to get errors that pointed out the usual forgotton punctuation and mispellings in the external file. After I corrected those, the object expected error returned.

Khalid Ali
07-16-2003, 10:30 AM
I submitted the form twice without any error..

Mozilla 1.4

Please give the exact scenario that causes this error

rmsonger
07-16-2003, 10:37 AM
Maybe it is IE6? I am clicking submit without filling in any of the fields to begin testing the validation. I need to fire up my BSD box and see what happens. Thanks

Mozilla 1.0.1 javascript console talls me that validateForm is not defined. Now the boy is extremely confused.

new edit...
used the w3c validator (thanks to a reply in another postby Charles) which cleaned up alot of garbage, now no more object expected. other things in the script do not work as I had hoped, but hey that's programming. thanks all