moneytree
01-27-2008, 10:34 AM
Hi everyone,
I am new to javascript and written the following script for the purpose of validating my opt-in form.
However,when I carried out a test by clicked on the submit button without filling in any field,to my suprise,it allowed for the submission without prompting any error message !
Please kindly review the following script and advice the errors in it.
--------------------------------------------------------------------------------------------------------
<div id="formbox">
<h3>Get Your Free Gifts !</h3>
<form METHOD="post" ACTION="http://moneymakeyourich.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="moneytree@moneymakeyourich.com">
<input type=hidden name="subject" value="Your Subject">
First Name :
<input type=text name="realname" size="20">
<br>
Last Name :
<input type=text name="lastname" size="20">
<br>
Email :
<input type=text name="email" size="20">
<br>
<input type="Submit" value="submit" onclick="verify()"/>
<script type="text/javascript">
<!--
function verify(){
var first=document entry first_name value;
var last=document entry last_name value;
var email=document entry email_address value;
var message="Please complete the following field(s): \n".
var errors="".
if(!first){
errors+="First name\n";
}
if(!last){
errors+="Last name\n";
}
if(!email){
errors+="email address\n";
}
if(errors){
alert(message+errors);
}
}
//-->
</form>
<p><b>Important</b>:I will never share your information with anyone !</p>
--------------------------------------------------------------------------------------------------------
Thank you.
Best regards
Manicui
I am new to javascript and written the following script for the purpose of validating my opt-in form.
However,when I carried out a test by clicked on the submit button without filling in any field,to my suprise,it allowed for the submission without prompting any error message !
Please kindly review the following script and advice the errors in it.
--------------------------------------------------------------------------------------------------------
<div id="formbox">
<h3>Get Your Free Gifts !</h3>
<form METHOD="post" ACTION="http://moneymakeyourich.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="moneytree@moneymakeyourich.com">
<input type=hidden name="subject" value="Your Subject">
First Name :
<input type=text name="realname" size="20">
<br>
Last Name :
<input type=text name="lastname" size="20">
<br>
Email :
<input type=text name="email" size="20">
<br>
<input type="Submit" value="submit" onclick="verify()"/>
<script type="text/javascript">
<!--
function verify(){
var first=document entry first_name value;
var last=document entry last_name value;
var email=document entry email_address value;
var message="Please complete the following field(s): \n".
var errors="".
if(!first){
errors+="First name\n";
}
if(!last){
errors+="Last name\n";
}
if(!email){
errors+="email address\n";
}
if(errors){
alert(message+errors);
}
}
//-->
</form>
<p><b>Important</b>:I will never share your information with anyone !</p>
--------------------------------------------------------------------------------------------------------
Thank you.
Best regards
Manicui