HighDots Forums  

Re: Newbie form validation question

Javascript JavaScript language (comp.lang.javascript)


Discuss Re: Newbie form validation question in the Javascript forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Lee
 
Posts: n/a

Default Re: Newbie form validation question - 10-13-2003 , 02:56 AM






Jason & Juli Cook said:

Quote:
function validateForm(myForm){
if (myForm.firstname.value==""||myForm.firstname.valu e==null){
alert("fix the firstname");
myForm.firstname.focus();
return(false);
}
alert("finished Name");

return validateDate(myForm.FirstDate);
alert("finished first date");

return validateDate(myForm.SecondDate);
alert("finished second date");

}
Imagine a friend sends his young child to you to ask you to check
some facts. You tell the child to return with the message that
the facts are correct. If you then check something else and try
to tell the child to return with the results of that, too, you'll
find that you're talking to yourself, because the child left the
first time you told him to return.

Return means "return". Now. Anything a function says to do after
a return statement is just talking to itself.


You might get what you want with:

return(validateDate(myForm.FirstDate)&&validateDat e(myForm.SecondDate));

That will run the first check and, if it is true, will also run the
second check, and if they're both true, will return "true". If either
check is false, the function will return "false".

Note that it won't make it clear to the user which date was wrong.



Reply With Quote
Reply




Thread Tools
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



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.