coder71 Posted August 30, 2007 Share Posted August 30, 2007 I've seen the posts on this, but the submit button is still not disabling on my page. The code is supposed to check the form for errors and then disable the submit button. It catches the errors, but won't disable the submit. What happens is that if everything is verified, it looks like the form posts and for a brief second the submit button disables. Then the form refreshes without actually posting the data. Here's the JS in the head: function disableForm(theform) { if (document.all || document.getElementById) { for (i = 0; i < theform.length; i++) { var tempobj = theform.elements; if (tempobj.type.toLowerCase() == "submit") tempobj.disabled = true; } return true; } } function validRequired(formField,fieldLabel) { var result = true; if (formField.value == "") { alert('Please enter a value for the "' + fieldLabel +'" field.'); formField.focus(); result = false; } return result; } function validateForm(theForm){ if (!validRequired(theForm.cardnumber,"Credit Card Number")){ return false; } if (!validRequired(theForm.cardexpmonth,"Expiration Month")){ return false;} if (!validRequired(theForm.cardexpyear,"Expiration Year")){ return false;} disableForm(theForm); return true; } Here's the form line: <form name="addjob3" action="<? PHP_SELF; ?>" method="POST" onsubmit="return validateForm(this)"> Here's the submit button: <input type="submit" name="submitp" value="Submit"> I've been trying this for literally a whole day. I can't get it and it's driving me nuts! I'd really appreciate someone helping me with this. I'm good with PHP but don't know much about JS at all. Quote Link to comment Share on other sites More sharing options...
coder71 Posted September 2, 2007 Author Share Posted September 2, 2007 oops... i meant to say "What happens is that if everything is verified, it looks like the form posts and for a brief second the submit button disables<b>, but then it re-enables and then</b> the form refreshes without actually posting the data. This is holding me up on completing this project. I've searched everywhere. Can anyone please help me with this? Quote Link to comment Share on other sites More sharing options...
coder71 Posted September 6, 2007 Author Share Posted September 6, 2007 i'm beggin' ya... 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.