FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General Coding/Development
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 04-12-2003, 01:00 PM   Postid: 85660
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
Stopping a for submit with javascript

Ok, I have a form that lets you log into the members only section. It is in a frame. I have a system set up so when you click login and you havn't entered anything you get an alert messag that says please enter text. But when I test it and click submit on it gives the alert and then reaload the frame but it takes up the whole page. I also don't want it to have reload either. Oh ya and the script executes when you submit the form.. Any help.
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Old 04-12-2003, 01:20 PM   Postid: 85661
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
http://javascript.internet.com/forms...ed-fields.html

Dan
dank is offline   Reply With Quote
Old 04-12-2003, 04:19 PM   Postid: 85670
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
That didnt help much. I know how to make the alert when they didnt put in the required field but I need to know how to stop the page from reloading itself. I don't know why it does.
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Old 04-12-2003, 04:38 PM   Postid: 85672
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
OK actually that did help but I already knew the return false thing. What I need to do is stop the page from reloading. At first it was realoading and taking up the entire frameset instead of its section but now the page just comes up with the error message and reloads. I need to stop it from reloading.
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Old 04-12-2003, 04:59 PM   Postid: 85677
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
When you say the frame is reloading, do you mean on a successful submit or even when data is missing on submission? If it is only after a successful submit, then I don't believe there's anything you can really do about that. That's just the way forms work... It has to go somewhere upon submission, otherwise the form doesn't get processed. Can't say I understand why you would be doing that in a frame...

Dan
dank is offline   Reply With Quote
Old 04-13-2003, 12:32 PM   Postid: 85704
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
On a successful submit it reloads but come up with a table stating their member name and giving them the option to logout. When they are missing something from the form then it come up with the alkert and reloads even when I put in return false. Im thinking that is the only way to stop it from reloading. I think I will just have to rewrite some of my scripts because that must be what is causing it (conflicting scripts). I am doing it in a frame so members have an easy way to login.
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Old 04-13-2003, 01:16 PM   Postid: 85708
dank
Registered User

Forum Notability:
410 pts: Community Guru
[Post Feedback]
 
Join Date: Mar 2000
Location: MWV
Posts: 3,986
Quote:
When they are missing something from the form then it come up with the alkert and reloads even when I put in return false.
You've probably got something slightly wrong in your code then. That shouldn't be happening... I would double check that you haven't added anything in incorrect relative to the example script. If in doubt, install just that example code into your frame and see if it works properly, then start adjusting it to your own needs.

Dan
dank is offline   Reply With Quote
Old 04-13-2003, 04:21 PM   Postid: 85721
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
Hey I just noticed you from Salem. Im from Oregon City. Any way ya I would start form scratch with the example script but it would mean me just starting over. Its not a simple script i ahve been working on it for quite a while. I think I might be forced to start over any way. It is getting really complex and it might not work on helf the browsers.
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Old 04-14-2003, 11:29 PM   Postid: 85890
Confused
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Tokyo, Japan
Posts: 1
stopping form submission

return false;

that is your answer!

first of all ... make sure you refernce your script to check for form input on the submission .... this can be done a number of ways ....

then when checking you forms fields ....


if($username=="" || $password==""){//or what ever checks you are doing
alert('hey you fool, you must actually log in to be logged in!');
return false;
}else{
return true;
}

I usually replace the submit button with a regular button object then use the onclick handler to check with the script for data validity then use


if($username=="" || $password==""){
alert('some not so rude message, maybe?');
return false;
}else{
document.forms[0].submit();//you may use the form name too, of course
}

another point is to be SURE to check the data validity of the server ANYWAY!
You must still assume that you have invalid or no data when the form is submitted. This is for security reasons. This JS type validation is really best used to ensure that if data isn't input or is in the wrong format the user doesn't have to re-type it all....using the return false doesn't clear the fields.....
Confused is offline   Reply With Quote
Old 04-15-2003, 11:06 PM   Postid: 85968
eyeRmonkey
Visitor

Forum Notability:
0 pts:
[Post Feedback]
 
Join Date: Apr 2003
Location: Oregon...
Posts: 13
what is $name and $password?
__________________
- eye R. monkey
http://www.EliteBrotherhood.tk
eyeRmonkey is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 06:08 PM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.