rick2302 Posted October 8, 2008 Share Posted October 8, 2008 I check my form for changes, and if there are any, my validator returns false, else, true. Trouble is, regardless of the return value, the form is always submitted (it just navigates to another page). <form name="returnMainMenuform" action="administration.php" method="post"> <input type="submit" class="buttonStd2" name="cancel" value="Main Menu" onclick="return confirmDataLoss()" /></form> the code below DOES work, but I'd rather not do it this way, due to some other controls on the page: <form name="returnMainMenuform" action="administration.php" method="post" onsubmit="return confirmDataLoss()"> <input type="submit" class="buttonStd2" name="cancel" value="Main Menu" /></form> Is there a way to get the first example to work?Thanks! Link to comment Share on other sites More sharing options...
rick2302 Posted October 8, 2008 Author Share Posted October 8, 2008 I decided to remove everything from the page piece by piece to try to track this down. It turns out that a new .js include is messing things up. So I think I am all set now; the code works without that .js include file. Now I just need to find out why.... but I am on my own for that...Thanks! Link to comment Share on other sites More sharing options...
rick2302 Posted October 8, 2008 Author Share Posted October 8, 2008 OK - I found the problem. The included .js file has a "return true" that is faking out my validator.I really kinda need this .js file, so as a workaround, is there a way that I can validate and return something other than true or false, like "valid" or "invalid", that I can use instead? I think I know how to return the value, but am not sure how to check to see what I got back.Any ideas?? Link to comment Share on other sites More sharing options...
jeffman Posted October 8, 2008 Share Posted October 8, 2008 Depends. Is confirmDataLoss() your function of the .js file's function? If it's yours, you need to set your return value in a different way. If it's the file's, then you should probably create a separate function for your submit handler, and confirmDataLoss() gets called from inside that function. Set your function's return value appropriately. Link to comment Share on other sites More sharing options...
rick2302 Posted October 9, 2008 Author Share Posted October 9, 2008 confirmDataLoss() is mine - I can return any value - it's just that I am not sure how I would be able to use anything other than true/false. I'd have to incorporate an If statement somewhere to see the return value, then decide how to proceed - not sure that would be done.For now I removed the part of the .js include file (not mine - but I can edit it) that was fooling my validator script - from what I can see, it will not reduce any noticable functionality - may just remove a convenience item - no big loss. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.