2 Replies Latest reply on Aug 3, 2006 10:39 AM by bregent

    My very first form

    TCarp Level 1
      For my very first form I want to create one where a visitor can submit an email address. I've been on the net learning as much as I can but I'd like to verify I'm understanding what I'm reading.

      I want to verify for a valid email address. It looks like there are a number of scripts that will do that. I'm studying the scripts that are available to see if I can understand them. Then I want the form sent via email. I've read that the new browsers don't support mailto so I went to my host (GoDaddy) and they seem to have a couple handlers. The cgi email handler I assume is the one I want. All they ask for is an email address set up on the account.

      How does the form get sent to the email handler?

      And can someone help me understand what this example is doing? Found it while doing research.

      function emailinput_on()
      {
      if(document.getElementById("email-addr").value=="Your email address")
      {
      document.getElementById("email-addr").value = "";
      }
      }

      function emailinput_off()
      {
      if(document.getElementById("email-addr").value=="")
      {
      document.getElementById("email-addr").value = "Your email address";
      }
      }

      function validate_email()
      {
      var alertbg = "#345f91";
      var okbg = "#ffffff";

      var email_regex = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,})+$/;

      if(!email_regex.test(document.getElementById("email-addr").value))
      {
      document.getElementById("email-addr").style.background = alertbg;
      document.getElementById("email-addr").focus();
      return false;
      }
      else
      {
      document.getElementById("email-addr").style.background = okbg;
      return true;
      }
      }

      It goes with this form:

      <form id="email-signup" action="email-thankyou.htm" method="post" onSubmit="return validate_email()">
      <p>
      <input id="email-addr" name="email-addr" value="Your email address" onFocus="emailinput_on()" onBlur="emailinput_off()">
      <input id="sbmt-image" name="sbmt-image" type="image" src="images/go_light_bg.gif" alt="Go">
      </p>
      </form>


      Tom
        • 1. Re: My very first form
          Level 7
          There are only two ways to process form data -

          1. Use mailto:name@domain.com as the action of the form
          2. Use a server-side scripting method to a) harvest the form's data, b)
          process it in some manner, e.g., enter it into a database, c) formulate and
          send an email to one or more email recipients, and d) redirect the visitor
          to some ending page

          Method 1 is quite simple, and is also the least reliable. It depends both
          on your visitor having an email client already installed on their computer -
          this eliminates public computers, or home users without email clients
          installed (more and more it seems) - and on the installed email client
          responding to
          the mailto call. It is not possible to use this method *and* send the
          visitor to a
          thank you page as well.

          Method 2 is the preferred method, since it eliminates the problems of method
          1, but it means that you have to grapple with server-scripting somehow (ASP,
          CF, PHP, perl, etc.).

          You would have to decide which of these methods is best for your needs,
          but if it's Method 2, then start by asking your host what they provide for
          form
          processing.

          --
          Murray --- ICQ 71997575
          Adobe Community Expert
          (If you *MUST* email me, don't LAUGH when you do so!)
          ==================
          http://www.dreamweavermx-templates.com - Template Triage!
          http://www.projectseven.com/go - DW FAQs, Tutorials & Resources
          http://www.dwfaq.com - DW FAQs, Tutorials & Resources
          http://www.macromedia.com/support/search/ - Macromedia (MM) Technotes
          ==================


          "TCarp" <webforumsuser@macromedia.com> wrote in message
          news:ears2d$2rm$1@forums.macromedia.com...
          > For my very first form I want to create one where a visitor can submit an
          > email
          > address. I've been on the net learning as much as I can but I'd like to
          > verify
          > I'm understanding what I'm reading.
          >
          > I want to verify for a valid email address. It looks like there are a
          > number
          > of scripts that will do that. I'm studying the scripts that are available
          > to
          > see if I can understand them. Then I want the form sent via email. I've
          > read
          > that the new browsers don't support mailto so I went to my host (GoDaddy)
          > and
          > they seem to have a couple handlers. The cgi email handler I assume is
          > the one
          > I want. All they ask for is an email address set up on the account.
          >
          > How does the form get sent to the email handler?
          >
          > Tom
          >


          • 2. Re: My very first form
            bregent Most Valuable Participant
            >Edited: 08/02/2006 at 09:03:12 PM by TCarp

            First of all, never edit your posts in this forum. Nobody on the nntp side will see all of the extra questions/code you just asked. Just add a new reply to the thread instead.

            In answer to your later question, the client side jscript code you posted is used to validate that the email address is in the proper form. It does not check it's a valid email address. Furthermore, client side validation is a nice feature to assist you visitors, but validation on the server side is mandatory.