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
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.