Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-08-2004, 03:57 AM   PM User | #1
jwindon
New Coder

 
Join Date: Jan 2004
Location: Kentucky
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
jwindon is an unknown quantity at this point
When to run data validation

I'm writing a validation function to check a form. I have it set to trigger with the submit button onClick. Problem is that is DOES trigger and run, but then the form still proceeds to process. Where should I put the command to run the function and what syntax do I use.

Thanks in advance.


This is related to my post at:

http://www.codingforums.com/showthre...2&goto=newpost
__________________
-- Always thankful for kind and patient teachers willing to help a beginner.
jwindon is offline   Reply With Quote
Old 01-08-2004, 09:04 AM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
Do not use onclick on the submit button. Leave it as it is (if a submit) and let the function to be fired from FORM tag by the event handler OnSubmit. Give a return condition here and specify the return true/false in the validate function.

<script>
function validate(){
if (true condition here){
return true;
}
else {
return false;
}
}
<script>
.
.
.
<body>
<form onsubmit = "return validate()">

.
.
.
<input type="submit">
</form>
</body>

Or use the false condition to return false, whatever....
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:51 PM.


Advertisement
Log in to turn off these ads.