Solved

Validating a Form

Posted on 2000-04-07
17
140 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
 

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
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
This article provides a case study on how our local youth baseball league deployed a new website, including the platform selection, implementation and benefits to the league.
The purpose of this video is to demonstrate how to add AdSense Ads to a WordPress Website, and how to set up WordPress to automatically place Ads in Sidebars. This will be demonstrated using a Windows 8 PC. Log into your AdSense account. : Cli…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

863 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now