/    Sign up×
Community /Pin to ProfileBookmark

error: object expected

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?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@Khalid_AliJul 16.2003 — 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 )">
Copy linkTweet thisAlerts:
@rmsongerauthorJul 16.2003 — 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.
Copy linkTweet thisAlerts:
@Khalid_AliJul 16.2003 — I submitted the form twice without any error..

Mozilla 1.4

Please give the exact scenario that causes this error
Copy linkTweet thisAlerts:
@rmsongerauthorJul 16.2003 — 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.

[I]new edit...[/I]

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
×

Success!

Help @rmsonger spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...