Wrox Programmer Forums
|
BOOK: Beginning JavaScript 2nd Edition For questions about Beginning Javascript 2nd Edition by Paul Wilton. (ISBN: 0-7645-5587-1). Published April 2004. For Javascript questions not specific to this book, please see the Javascript forum. If you have the 1st edition, please continue to use that forum instead at: http://p2p.wrox.com/forum.asp?FORUM_ID=21
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning JavaScript 2nd Edition section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 31st, 2004, 07:49 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default Help with my small validation script

I have a script that has 2 functions. Some way i need to be able to do the second function only if the first function returned true.. But have no clue how to do it..... If anyone could help that would be great!

Code:
function validate(objForm, returnvalue)
{
   //Validation Control Center
   //Use validateNotEmpty(fieldname,errormessage) to check if the field is empty
   //Use validateEMailCheck(fieldname,errormessage) to check if the email address is valid
   //These must go inside if statement
   var anError
   if (validateNotEmpty(objForm.Email.value,"You must enter your e-mail address")==false)
   {
      anError=true;
   }
   else if (validateEMailCheck(objForm.Email.value,"You must enter a valid e-mail address for yourself")==false)
   {
      anError=true
   }
   else if(objForm.SportsMailing.checked==false && objForm.GamingMailing.checked==false)
   {
      alert("You must choose at least one topic");
      anError=true;
   }
   if (anError==true)
   {
      return false;
   }
}
function popupform(myform, windowname)
{
if (! window.focus)return true;
window.open('', windowname, 'height=200,width=400,scrollbars=no');
myform.target=windowname;
return true;
}
 
Old August 31st, 2004, 08:55 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,285
Thanks: 0
Thanked 2 Times in 2 Posts
Default

For one thing, the first function cannot return true. You have no lines that say "return true;", only "return false;".

Anyway, to check if a function returns true, just use simple syntax like this:

if(someFunction(parameter1,parameter2,etc))
{
    doSomeFunction;
}

HTH,

Snib

<><





Similar Threads
Thread Thread Starter Forum Replies Last Post
Standalone validation + web form validation morbo Struts 0 August 19th, 2008 04:02 AM
Validation Script Teessider_2000 Javascript 7 January 5th, 2007 12:22 PM
Java Script Validation ricespn Classic ASP Basics 2 November 16th, 2006 02:05 PM
A small puzzle marianeeli C++ Programming 9 September 5th, 2006 12:02 AM
Need Small Help From a Noob!!! maximus101 VB.NET 2002/2003 Basics 9 April 7th, 2006 10:30 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.