I think you're misreading.  he is using the proper hierarchy.  the function was passed 'theForm' as an object, so a reference within the function to theForm.EMailAddress.value is the same as window.document.form1.EMailAddress.value.

As far as why the form submits...it shouldn't matter whether or not you have ASP or CF (or PHP or JSP etc) on the back end.  JS is all client side.  It's submitting because there's an error somewhere in the JS (if you're using IE, look at the bottom left corner as you hit submit, and you should see a yellow error icon).

The only thing I might suggest in looking at the code you posted is to remove the parentheses from your return statements.

eg do:  return false and return true instead of return (false) and return (true).

hth,
Charlie

  ----- Original Message -----
  From: MILAN MUSHRAN
  To: CF-Talk
  Sent: Wednesday, December 17, 2003 9:54 AM
  Subject: RE: _javascript_ Issue on CFMX 6.1

  Change the name of the form to "theform". Also, try to get into the habit of
  using the proper hierarchy -
  "window.document.formname.fieldname.value" for netscape compatibility.

  >From: "Bailey, Neal" <[EMAIL PROTECTED]>
  >Reply-To: [EMAIL PROTECTED]
  >To: CF-Talk <[EMAIL PROTECTED]>
  >Subject: _javascript_ Issue on CFMX 6.1
  >Date: Wed, 17 Dec 2003 10:25:38 -0600
  >
  >Hey guys,
  >
  >I need a little _javascript_ help. I use the following script to validate two
  >form fields. It's an either or script and it works on an ASP page but when
  >running on CF MX 6.1 it only partially works. When you get prompted to fill
  >in the requested field and select "OK" to continue it still process the
  >form
  >instead of halting. Any ideas...
  >
  ><!--- Start of Validation Script --->
  ><script Language="_javascript_">
  >  <!--
  >  function Form1_Validator(theForm)
  >  {
  >
  >    if ((theForm.EMailaddress.value == "") && (theForm.BusinessPhone.value
  >==
  >"") && (theForm.HomePhone.value == ""))
  >    {
  >      alert("Please enter a value for a \"Phone Number\" or the \"EMail
  >Address\" field.");
  >      theForm.EmailAddress.focus();
  >      return (false);
  >    }
  >
  >    return (true);
  >  }
  >  -->
  >  </script>
  ><!--- End of Validation Script --->
  >
  >
  ><!--- Start of Form --->
  ><form name="form1" method="post"
  >action="">   > >&pg=15" Form1_Validator(this)">
  >
  >Phone: <input type="text" name="HomePhone">
  >
  >Email: <input type="text" name="EMailaddress">
  >
  ></form>
  ><!--- End of Form --->
  >
  >I'm not a _javascript_ person so if you know of a better script that does the
  >same thing let me know. Thanks.
  >
  >Neal Bailey
  >Internet Marketing Manager
  >UGA-Association Field Services
  >E-mail:  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED]
  >
  >This email and any files transmitted with it are confidential and intended
  >solely for the use of the individual or entity to whom they are addressed.
  >If you are not the named addressee you should not disseminate, distribute
  >or
  >copy this e-mail.  Please notify the sender immediately by e-mail if you
  >have received this e-mail by mistake and delete this e-mail from your
  >system.  If you are not the intended recipient you are hereby notified that
  >disclosing, copying, distributing or taking any action in reliance on the
  >contents of this information is strictly prohibited.  Thank you.
  >
  >
  >
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to