Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 155
  • Last Modified:

Validating a Form

Hi!  I just made a neat form on one of my pages.  I accept someone's email address.  Is therer any way I can add a validate within FP to check to see if the text they enter contains a @?  If it does not have an @ symbol in the text and they press submit they get an error.  500dll error, I Would like to perform an error check before that.
Thanks

Leo
0
lcrr
Asked:
lcrr
  • 11
  • 6
1 Solution
 
TTomCommented:
This is pretty simple to do using JavaScript.

Adding this code to your page (replacing as appropriate) will give you something workable:

<script>
function validate() {
      if (document.frm.T1.value.indexOf("@") == -1) {
            alert("invalid email address");
            return false;
      }
}
</script>
</head>

<body>

<form method="POST" action="--WEBBOT-SELF--" onsubmit="return validate();" name=frm>
0
 
lcrrAuthor Commented:
Hi TTom,
  Thanks for your quick response.  I understand the first part with the JS.  I do not understand the second part with the form method part.  I will include my form method statement, so you can explain how to use with that.

<form method=POST action="http://www.youwillmakemoney.com/cgi-bin/cgiemail/referral.txt">

Thanks
Leo
0
 
lcrrAuthor Commented:
Adjusted points from 14 to 28
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 
lcrrAuthor Commented:
Hi!  I just doubled the point value of this question.  
Thanks
Leo
0
 
TTomCommented:
<script>
function validate() {
if (document.frm.T1.value.indexOf("@") == -1) {
alert("invalid email address");
return false;
}
}
</script>

<form name=frm method=POST action="http://www.youwillmakemoney.com/cgi-bin/cgiemail/referral.txt" onsubmit="return validate();">

The only other thing you should need to do is to be sure the input box for your email address is name T1 (or, be sure that the name of the box mathches that in the script).

BTW, JavaScript is CASE SENSITIVE, so be careful about naming things.

Tom

0
 
lcrrAuthor Commented:
Adjusted points from 28 to 35
0
 
lcrrAuthor Commented:
Hi,
  I installed that code and it is still processing the forms.  I will include a list of the WHOLE page so that you can see all my variables.  I am not very good at JavaScript, so I am not sure what to do.  Since this question, is much harder than I originally though, I have increased the points again.  
Thanks
Leo
0
 
lcrrAuthor Commented:

<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>You Will Make Money:Private:Referral</title>
<style>
a{text-decoration:none}
</style>
<script>
function validate() {
if (document.frm.emal.value.indexOf("@") == -1) {
alert("Invalid Email Address");
return false;
}
}
</script>

</head>

<body>


<form method=POST action="http://www.youwillmakemoney.com/cgi-bin/cgiemail/referral.txt" onsubmit="return validate();">

              <INPUT TYPE=HIDDEN VALUE="http://www.youwillmakemoney.com/" name="success">
                    <table border="0" width="100%">
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Your
                          Name:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="nam" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Your
                          Email Address:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="emal" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="17" align="right"><font face="Arial">Your
                          ClickBank ID:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="17"><font face="Arial"><input type="text" name="clickbankID" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="100%" height="19" align="right" colspan="2"></td>
                      </tr>
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Friend's
                          Email:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="frend1" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Friend's
                          Email:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="frend2" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Friend's
                          Email:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="frend3" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="23" align="right"><font face="Arial">Friend's
                          Email:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="23"><font face="Arial"><input type="text" name="frend4" size="24"></font></td>
                      </tr>
                      <tr>
                        <td width="36%" height="24" align="right"><font face="Arial">Friend's
                          Email:&nbsp;&nbsp;</font></td>
                        <td width="64%" height="24"><font face="Arial"><input type="text" name="frend5" size="24"></font></td>
                      </tr>
                    </table>
                    <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="submit" value="Announce" name="B1">&nbsp; <input type="reset" value="Clear" name="B2"></p>
                  </form>
                  <p>&nbsp;
                </td>
              </tr>
            </table>
            <font color="#FFFFFF" face="Arial Black" size="2">&nbsp;</font><font face="Arial" size="3"><font color="#FFFFFF">&nbsp;&nbsp;&nbsp;&nbsp;<br>
            </font></font>
            <font color="#000000" face="Arial" size="3">
<br>
<p>&nbsp;

</p>
</body>

</html>
0
 
TTomCommented:
You forgot to add a name to the form.

<form name=frm...> will make this piece work.

Tom
0
 
lcrrAuthor Commented:
Adjusted points from 35 to 40
0
 
lcrrAuthor Commented:
Could you tell me where to place this line of text and the exact syntax?  
I did not know I needed to name forms.
Thanks
Leo
PS added more points
0
 
TTomCommented:
Change this line:

<form method=POST action="http://www.youwillmakemoney.com/cgi-bin/cgiemail/referral.txt" onsubmit="return validate();">

to

<form method=POST action="http://www.youwillmakemoney.com/cgi-bin/cgiemail/referral.txt" onsubmit="return validate();" name=frm>

Naming the form is only necessary if you want to be able to access the form or its elements in a script.

Tom

0
 
lcrrAuthor Commented:
Adjusted points from 40 to 50
0
 
lcrrAuthor Commented:
Hi,
  I have the page up and runing now.  When the person enters an invalid email address, the alert pops up, but when they enter a valid email address it does not send the mail.  I tested this several times and waiting 20 minutes just in case of delay with my mail server.  
Here is a link to the page.  Any suggestions would be appreciated.

http://www.youwillmakemoney.com/testreferral.html

Leo
ps.  I upped the points again. This is way harder than I originally thought.
0
 
TTomCommented:
Leo:

The form as it is coded is calling a CGI script, supposedly to send an email message.  You will need to verify with whomever is in charge of your server that this process is working properly.  I can't help you there.

Tom
0
 
lcrrAuthor Commented:
Hi TTOM,
  I got it all up and working!  
Thanks so much!  
Leo
0
 
TTomCommented:
Most welcome!

Tom
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 11
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now