The Little Guy Posted February 28, 2008 Share Posted February 28, 2008 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> Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 It looks to me like it should work. So since it doesn't, replace the code in error with this: var target = document.getElementById("loginForm") target.submit() note: does it work if you click the submit button? Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 same error here is the page: Page: http://beta.tzfiles.com/ top right form username: demo password: demo12 Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 Take off the leading slash in the action of your form tag. I believe that is your problem. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 Nope still same error. Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 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. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 still doesn't work. Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 Keep on trying! Change the type in your submit button from 'button' to 'submit'. That solves the problem of the form not submitting at all. After you do that, lets work on the javascript. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 OK it is a submit Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 now change the 'name' attribute from 'submit' to 'submit_form'. Quote Link to comment Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 fixed it! It was because I had my button named: id="submit" name="submit" I changed them to id="submitBtn" name="submitBtn" Quote Link to comment Share on other sites More sharing options...
haku Posted February 28, 2008 Share Posted February 28, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.