Jump to content

submit is not a function error


The Little Guy

Recommended Posts

When I press the submit button, I get an error saying:

Error: document.loginForm.submit is not a function

Source File: http://beta.tzfiles.com/

Line: 123

 

function checkLogin(){
var good = true;
if(document.getElementById('usrNT').value.length < 1){
	document.getElementById('usrN').style.color = '#FF0000';
	good = false;
}else{
	document.getElementById('usrN').style.color = '#000000';
	good = true;
}
if(document.getElementById('usrPT').value.length < 1){
	document.getElementById('usrP').style.color = '#FF0000';
	good = false;
}else{
	document.getElementById('usrP').style.color = '#000000';
	good = true;
}
if(good){
	document.loginForm.submit();
}
}

 

 

		<form id="loginForm" name="loginForm" action="/process/login.php" method="post">
		<p><label id="usrN" for="user">Username:</label> <input onkeydown="javascript:hitkey(event);" id="usrNT" type="text" id="user" name="user" size="10" />   
		<label id="usrP" for="pass">Password:</label> <input onkeydown="javascript:hitkey(event);" id="usrPT" name="pass" id="pass" type="password" size="10" />
		<input id="submit" name="submit" value="Login" type="button" onclick="checkLogin();"></p>
	</form>

Link to comment
https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/
Share on other sites

First, try to get it working without javascript. You are missing the closing slash on your input button. Add that, then lets see what happens. This shouldn't affect your javascript, but I'm thinking its not a javascript issue at this point, as it doesnt work even with javascript off.

 

edit: I'm slow tonite. 'Name' is deprecated for form elements. Take away the name in your form tag, and use the submit code I posted earlier that has the getElementById in order to submit the form.

Thats what I was thinking at the end, which is why I told you to change the name. The ID was no problem, but the fact that you had buttons with the name 'submit' was making the javascript think that 'submit' was an object, not a function. Thats where the conflict was coming from.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.