Solved

Validating a Form

Posted on 2000-04-07
17
139 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
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points from 14 to 28
0
 

Author Comment

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

Expert Comment

by:TTom
Comment Utility
<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
Comment Utility
Adjusted points from 28 to 35
0
 

Author Comment

by:lcrr
Comment Utility
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
Comment Utility

<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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 9

Expert Comment

by:TTom
Comment Utility
You forgot to add a name to the form.

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

Tom
0
 

Author Comment

by:lcrr
Comment Utility
Adjusted points from 35 to 40
0
 

Author Comment

by:lcrr
Comment Utility
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
Comment Utility
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
Comment Utility
Adjusted points from 40 to 50
0
 

Author Comment

by:lcrr
Comment Utility
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
Comment Utility
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
Comment Utility
Hi TTOM,
  I got it all up and working!  
Thanks so much!  
Leo
0
 
LVL 9

Expert Comment

by:TTom
Comment Utility
Most welcome!

Tom
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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.
Objective of This Article In 1990’s, when I was a budding software professional, I had a lot of confusion about which stream or technology, I had to choose to build my career. In those days, I had lot of confusion like whether to choose System so…
The purpose of this video is to demonstrate how to insert an Iframe into WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Open Page or Post…
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…

763 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

15 Experts available now in Live!

Get 1:1 Help Now