Solved

Validating a Form

Posted on 2000-04-07
17
145 Views
Last Modified: 2013-12-24
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
Comment
Question by:lcrr
  • 11
  • 6
17 Comments
 
LVL 9

Expert Comment

by:TTom
ID: 2695111
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
 

Author Comment

by:lcrr
ID: 2697173
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
 

Author Comment

by:lcrr
ID: 2697174
Adjusted points from 14 to 28
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:lcrr
ID: 2697175
Hi!  I just doubled the point value of this question.  
Thanks
Leo
0
 
LVL 9

Expert Comment

by:TTom
ID: 2700087
<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
 

Author Comment

by:lcrr
ID: 2701049
Adjusted points from 28 to 35
0
 

Author Comment

by:lcrr
ID: 2701050
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
 

Author Comment

by:lcrr
ID: 2701060

<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
 
LVL 9

Expert Comment

by:TTom
ID: 2701172
You forgot to add a name to the form.

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

Tom
0
 

Author Comment

by:lcrr
ID: 2701432
Adjusted points from 35 to 40
0
 

Author Comment

by:lcrr
ID: 2701433
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
 
LVL 9

Accepted Solution

by:
TTom earned 50 total points
ID: 2701441
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
 

Author Comment

by:lcrr
ID: 2701844
Adjusted points from 40 to 50
0
 

Author Comment

by:lcrr
ID: 2701845
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
 
LVL 9

Expert Comment

by:TTom
ID: 2701923
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
 

Author Comment

by:lcrr
ID: 2702087
Hi TTOM,
  I got it all up and working!  
Thanks so much!  
Leo
0
 
LVL 9

Expert Comment

by:TTom
ID: 2702152
Most welcome!

Tom
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Nodejs not returning the response body as expected 4 150
monthly fee and support for nutrionist 3 143
Collapseable list of URLs. 10 140
Detailed steps to upload 6 53
Now that Expression Web 4.0 (http://www.microsoft.com/expression/products/Upgrade.aspx) is free if you buy or have the full version of Expression Web 3.0, now is the best time to  migrate from FrontPage to Expression Web (http://www.frontpage-to-exp…
Turn A Profile Picture Into A Cartoon Using Photoshop And Illustrator This tutorial will teach you how to make a cartoon style image out of a regular picture. I have tried to keep the tutorial as simple as possible. I used Adobe CS4 for this tuto…
The purpose of this video is to demonstrate how to create a Printer Friendly PDF on a WordPress Page. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome Screenshot” Google Chrome Extension, and SmallPDF.com Log…
The purpose of this video is to demonstrate how to automatically show related posts at the bottom of a blog post in WordPress. This will be demonstrated using a Windows 8 PC. Plugin “Yet Another Related Posts Plugin” will be used. Go to your…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question