...

View Full Version : When to run data validation



jwindon
01-08-2004, 03:57 AM
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/showthread.php?threadid=31212&goto=newpost

Kor
01-08-2004, 09:04 AM
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....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum