Jump to content

What happen to validation function on my two webform ? Thanks.


moneytree

Recommended Posts

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            :

<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          

: <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

 

 

 

 

 

 

 

Link to comment
Share on other sites

 

 

now it works... open & close brackets while calling function

 

 

onclick="verify1()"

 

<html><head><script language="javascript">

function verify1()
{

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();
}
}


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>
</head>



<body>

<form name="myform" METHOD="post" ACTION="">
<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            :
<input type=text name="Email" size="20">


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

</form>





<form name="myform2" METHOD="post" ACTION="">
<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           
: <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>

</body></html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.