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> Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/ 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? Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479288 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 Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479290 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. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479305 Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 Nope still same error. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479307 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. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479319 Share on other sites More sharing options...
The Little Guy Posted February 28, 2008 Author Share Posted February 28, 2008 still doesn't work. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479347 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. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479356 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 Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479369 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'. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479370 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" Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479373 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. Link to comment https://forums.phpfreaks.com/topic/93535-submit-is-not-a-function-error/#findComment-479375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.