theform.submit not a function

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

theform.submit not a function

Post by kendall »

I've seen this in the forum alot but none of the solutions provided are working so maybe there is a different reason for my error

I have built a form validation script that on a "onsubmit=checkForm() return false;" the script validates the form and submits it on a successful validation

Code: Select all

function checkForm(){
theform = document.forms[0];

// validation

if(!error)
theform.submit();
}
I have used this script over and over on many forms and has worked without flaws

however on this particular form...

1. the html is actually being included via php.
2. there are other javascripts being included (however, no errors are being reported and are not related to the form). This includes some ajax scripting.

the validation function executes as it should as trying to submit an empty form will bring up validation error alerts without script errors. but on successfull validation the debugging in firefox shows a
theform.submit is not a function
in the console

i did a

Code: Select all

alert(theform.name);
and was able to get the name of the form successfully so it cant be that it isnt finding the form.

is there any policy concerning this that needs to be followed? I do not see a reason why there would be such an error if the functions recognises the form

feyd | it's

Code: Select all

 not [code="..."] :P[/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

When "theform.submit is not a function" appears, an element named "submit" is not far behind. :)
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

ooohhhhhhhh....

8O
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Inside the event handler, 'this' refers to the object that triggered the event.

Code: Select all

function checkForm(){
// validation
error = false;

if (!error) this.submit();

} 
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

nickvd wrote:Inside the event handler, 'this' refers to the object that triggered the event.

Code: Select all

function checkForm(){
// validation
error = false;

if (!error) this.submit();

} 

Hmmm... are you sure...I ttried it but im getting a javascript alert on "this" and it turns up [object window] and gives me no reference to the form

im using the forms "onsubmit" to trigger the form validation.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

When you use

Code: Select all

form.submit()
does the "submit" button value get $_POSTED?
[/syntax]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Only if that is the browser's behavior. Some don't submit the button unless clicked. This is why I tell people to never look for the submit button when attempting to detect a submission.
User avatar
kendall
Forum Regular
Posts: 852
Joined: Tue Jul 30, 2002 10:21 am
Location: Trinidad, West Indies
Contact:

Post by kendall »

feyd wrote:Only if that is the browser's behavior. Some don't submit the button unless clicked. This is why I tell people to never look for the submit button when attempting to detect a submission.

oooohhhhhh 8O
Post Reply