Go Back  HTML Forums - Free Webmaster Forums and Help Forums > WEBSITE DEVELOPMENT > Client Side Scripting
User Name:
Password:
 

Reply
Thread Tools   Display Modes
  View First Unread
 
Old 04-15-2008, 05:38 PM
  #1
moneytree
Fighter (Level 4)
 
Join Date: Jan 2008
Posts: 33
iTrader: (0)
moneytree is an unknown quantity at this point
Please kindly advice what's wrong with this validation on webform,thanks.

Hi everyone,

I had tried to set-up the validation function for two webform on my site,however,it didn't work.Please kindly advice what's the caused of it.The following is the two webform code extracted from my home page for your review.

<script language="javascript">

function verify()
{

var errors1 = "";
var errors2 = "";
var errors3 = "";
var message="Please complete the following field(s): \n";

var first = document.myform.firstname.value;
var last = document.myform.lastname.value;
var email = document.myform.email.value;

if (first.length == "0") {
errors1="First name\n";
}
if (last.length == "0") {
errors2="Last name\n";
}
if (email.length == "0") {
errors3="email address\n";
}
if (errors1.length >= "1" || errors2.length >= "1" || errors3.length >= "1") {
alert(message + "\n\n" + errors1 + errors2 + errors3);
}
else {
document.myform.submit();
}
}


function verify2()
{

var errors1 = "";
var errors2 = "";
var errors3 = "";
var message="Please complete the following field(s): \n";

var first = document.myform2.firstname.value;
var last = document.myform2.lastname.value;
var email = document.myform2.email.value;

if (first.length == "0") {
errors1="First name\n";
}
if (last.length == "0") {
errors2="Last name\n";
}
if (email.length == "0") {
errors3="email address\n";
}
if (errors1.length >= "1" || errors2.length >= "1" || errors3.length >= "1") {
alert(message + "\n\n" + errors1 + errors2 + errors3);
}
else {
document.myform2.submit();
}
}

</script>
-->



<!-- First Form -->

<form name="myform" METHOD="post" ACTION="http://abc.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="newsletter@abc.com">
<input type=hidden name="subject" value="Thank you for subscribing to newsletter !">
First Name :
<input type=text name="firstname" size="20">


Last Name :
<input type=text name="lastname" size="20">


Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :
<input type=text name="Email" size="20">


<center><input type="submit" value="Yes,I want it !"/></center>

</form>





<form name="myform2" METHOD="post" ACTION="http://abc.com/cgi-bin/formmail.pl">
<input type=hidden name="recipient" value="ebook@abc.com">
<input type=hidden name="subject" value="Thank you for subscribing to ebook !">

<P align=center>First Name : <INPUT
title="Your Google Toolbar can fill this in for you. Select AutoFill"
style="BACKGROUND-COLOR: #ffffa0" name=firstname><BR>Last Name : <INPUT
title="Your Google Toolbar can fill this in for you. Select AutoFill"
style="BACKGROUND-COLOR: #ffffa0"
name=lastname><BR>Email&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
: <INPUT title="Your Google Toolbar can fill this in for you. Select AutoFill"
style="BACKGROUND-COLOR: #ffffa0" name=email><BR></P>
<CENTER><INPUT type=button value="Yes,I want the private access now !" onclick="verify2"></CENTER>

</form>


Many thanks for your time and efforts in helping me to solve this issue.

Best regards
manicui
moneytree is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 04-15-2008, 06:41 PM
  #2
Clueful
Hero (Level 10)
 
Join Date: Feb 2008
Posts: 95
iTrader: (0)
Clueful is on a distinguished road
Quote:
Originally Posted by moneytree View Post

<script language="javascript">
<script type="text/javascript">
Quote:
if (first.length == "0")
The length property is not a string, so compare it to an integer.
Code:
if (first.length == 0)
Quote:
document.myform.submit();
Don't call the submit method; assign your validation function to the form's onsubmit handler
Quote:
onclick="verify2"
Should be
Code:
onclick="return verify2()"
, although this is inferior to assigning the validator as the onsubmit event handler:
Code:
<form onsubmit='return verify()' ...........>
Clueful is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Old 04-16-2008, 08:18 AM
  #3
moneytree
Fighter (Level 4)
 
Join Date: Jan 2008
Posts: 33
iTrader: (0)
moneytree is an unknown quantity at this point
Hi Clueful,

Many thanks for your kind responsed to my query over webform issue.

There're two webform on my site and both failed to validate the firstname,lastname and email address,it even allowed to submit the opt-in simply by clicking on the submit button.

I had tried to made some changes,but,it failed to work.The drop-down webform seems a bit confussing,when you clicked on submit button,it did show the pop-up validation box,but when you clicked on ok button of the pop-up,it submitted the opt-in by itself !

Please kindly review and advice the cuased to it at my site www.moneymakeyourich.com

Thank you for your time and efforts in helping me.

Best regards
manicui

Last edited by moneytree : 04-16-2008 at 08:30 AM.
moneytree is offline   Add to del.icio.us Add to del.icio.us    Can you digg it?Can you digg it? Reply With Quote
Reply
KEEP TABS
SPONSORS
 
Boxedart

 
 


 
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
  
 
 
 



 
  POSTING RULES
 
 
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Thread Tools
Display Modes

Forum Jump

 

All times are GMT -5. The time now is 05:37 AM.

   

Mascot team created by Drawshop.com

Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.

Server Monitoring by ENIACmonitor 0.01
HTMLforums.com © Big Resources, Inc. Web Design by BoxedArt.com
vRewrite 1.5 beta SEOed URLs completed by Tech Help Forum and Chalo Na.