I'm very new to javascript so forgive my naive sense of things...
i have a registration form which is available at The form is linked to the file check.js which is to check for empty fields and to validate that the two passwords are the same...It is shown here:
Code:
Set in my regular page it does not work, meaning the script will not change the classes to notify the user of an error...HOWEVER...if i remove all of the other classes in the page: It works fine.
I've looked at all of the code and i dont understand, but like i said i'm new to this and i got this script out of a book i bought on javascript.
Code for registration1.php
HTML Code:
Code for reg2.php
HTML Code:
any help would be great
Reply With Quote
i have a registration form which is available at The form is linked to the file check.js which is to check for empty fields and to validate that the two passwords are the same...It is shown here:
Code:
Code:
window.onload = initForms;
function initForms() {
for (var i=0; i< document.forms.length; i++) {
document.forms[i].onsubmit = function() {return validForm();}
}
}
function validForm() {
var allGood = true;
var allTags = document.getElementsByTagName("*");
for (var i=0; i<allTags.length; i++) {
if (!validTag(allTags[i])) {
allGood = false;
}
}
return allGood;
function validTag(thisTag) {
var outClass = "";
var allClasses = thisTag.className.split(" ");
for (var j=0; j<allClasses.length; j++) {
outClass += validBasedOnClass(allClasses[j]) + " ";
}
thisTag.className = outClass;
if (outClass.indexOf("invalid") > -1) {
thisTag.focus();
if (thisTag.nodeName == "INPUT") {
thisTag.select();
}
return false;
}
return true;
function validBasedOnClass(thisClass) {
var classBack = "";
switch(thisClass) {
case "":
case "invalid":
break;
case "reqd":
if (allGood && thisTag.value == "") classBack = "invalid ";
classBack += thisClass;
break;
default:
if (allGood && !crossCheck(thisTag,thisClass)) classBack = "invalid ";
classBack += thisClass;
}
return classBack;
}
function crossCheck(inTag,otherFieldID) {
if (!document.getElementById(otherFieldID)) return false;
return (inTag.value == document.getElementById(otherFieldID).value);
}
}
}
Set in my regular page it does not work, meaning the script will not change the classes to notify the user of an error...HOWEVER...if i remove all of the other classes in the page: It works fine.
I've looked at all of the code and i dont understand, but like i said i'm new to this and i got this script out of a book i bought on javascript.
Code for registration1.php
HTML Code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Gayle Lanphier - Nutrition : Services</title>
<style type="text/css" media="all">
<!--
@import url([URL unfurl="true"]http://www.digiconmediagroup.com/Homeplate/hpn.css);[/URL]
-->
.style1 {
text-align: right;
}
</style>
<script language="javascript" type="text/javascript" src="check.js">
</script>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="Logocorner" class="style1">
Gayle Lanphier
<div id="logodisc">
Nutrition Consulatant</div><!--logodisc-->
</div><!--logocorner-->
<div id="pageheader">
</div><!--pageheader-->
</div><!--header-->
<div id="main">
<div id="nuttip">
<div id="nuttiphead">
Nutrition Tip of the Day
</div><!--nuttiphead-->
<div id="nuttipcont">
<?php echo file_get_contents('[URL unfurl="true"]http://www.digiconmediagroup.com/Homeplate/tip.txt');[/URL] ?>
</div><!--nuttipcont-->
</div><!--nuttip-->
<div id="mainnav">
<div id="mainnavhead">
Categories
</div><!--mainnavhead-->
<div id="navcont">
<div id="categories" class="boxed">
<div class="content">
<ul>
<li class="first">
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/">[/URL]
Welcome</a></li>
<li>
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/about/">[/URL]
About Gayle</a></li>
<li>
<a href="#">
<strong>Services</strong></a></li>
<li><a href="#">Member Portal</a></li>
<li>
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/photo/">[/URL]
Photo Gallery</a></li>
<li>
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/events/">[/URL]
Upcoming Events</a></li>
<li>
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/contact/">[/URL]
Contact</a></li>
</ul>
</div><!--content-->
</div><!--categories-->
</div><!--navcont-->
</div><!--mainnav-->
<div id="maincont">
<span class="post title">Member Portal Registration</span><span class="post posteda">All Fields Required</span>
<form action="#" class="regtxt">
<table style="width: 100%">
<tr>
<td class="regtxtb" style="height: 30px">Username:</td>
<td class="regtxtc" style="height: 30px">
<input name="username" type="text" class="reqd" tabindex="1"/></td>
<td class="regtxtb" style="height: 30px"> </td>
<td style="height: 30px"> </td>
</tr>
<tr>
<td class="regtxtb" style="height: 30px">Password:</td>
<td class="regtxtc" style="height: 30px">
<input name="passwd1" type="password" id="passwd1" class="reqd" tabindex="2"/></td>
<td class="regtxtb" style="height: 30px">Verify Password:</td>
<td class="regtxtc" style="height: 30px">
<input name="passwd2" type="password" id="passwd2" class="reqd" tabindex="3" /></td>
</tr>
<tr>
<td class="line" style="height: 18px" colspan="4">
<img alt="" src="images/line.png" width="515" height="5" /></td>
</tr>
<tr>
<td class="regtxtb" style="height: 30px">First Name:</td>
<td class="regtxtc" style="height: 30px"><input name="fname" type="text" class="reqd" tabindex="4" /></td>
<td class="regtxtb" style="height: 30px">Topic of Interest:</td>
<td class="regtxtc" style="height: 30px">
<input name="interest" type="text" class="reqd" tabindex="7" /></td>
</tr>
<tr>
<td class="regtxtb" style="height: 30px">Last Name:</td>
<td class="regtxtc" style="height: 30px"><input name="lname" type="text" class="reqd" tabindex="5" /></td>
<td class="regtxtb" style="height: 30px">Favorite Food:</td>
<td class="regtxtc" style="height: 30px">
<input name="food" type="text" class="reqd" tabindex="8" /></td>
</tr>
<tr>
<td class="regtxtb" style="height: 30px">E-mail Address:</td>
<td class="regtxtc" style="height: 30px">
<input name="email" type="text" class="reqd" tabindex="6" /></td>
<td class="regtxtb" style="height: 30px">Favorite Sport:</td>
<td class="regtxtc" style="height: 30px"><input name="sport" type="text" class="reqd" tabindex="9" /></td>
</tr>
<tr>
<td style="height: 25px" valign="top"> </td>
<td> </td>
<td> </td>
<td class="regtxtc" style="height: 30px">
<input name="Submit" type="submit" value="submit" tabindex="10" /> </td>
</tr>
</table>
</form>
</div><!--maincont-->
<!--services-->
<div id="footer" class="style1">
<span class="foorterlink">[
<a href="[URL unfurl="true"]http://digiconmediagroup.com/Homeplate/info/granola.htm">Nuts[/URL]
About Granola</a> |
<a target="_blank" href="[URL unfurl="true"]http://www.eatright.org/">[/URL]
American Dietetic Association</a> |
<a target="_blank" href="[URL unfurl="true"]http://www.gssiweb.com">Gatorade[/URL] Sports Science</a>
]<br />
<span class="post posted">© 2007 Digicon Media Group | Gayle Lanphier
RD, LDN does not endorse the content, products or services of other Web
sites.</span></span></div><!--footer-->
</div><!--main-->
</div><!--wrapper&table-->
</body>
</html>
Code for reg2.php
HTML Code:
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
<html xmlns="[URL unfurl="true"]http://www.w3.org/1999/xhtml">[/URL]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>Gayle Lanphier - Nutrition : Services</title>
<style type="text/css" media="all">
<!--
@import url([URL unfurl="true"]http://www.digiconmediagroup.com/Homeplate/hpn.css);[/URL]
-->
.style1 {
text-align: right;
}
</style>
<script language="javascript" type="text/javascript" src="check.js">
</script>
</head>
<body>
<form action="#">
<table style="width: 100%">
<tr>
<td style="height: 30px">Username:</td>
<td style="height: 30px">
<input name="username" type="text" class="reqd" tabindex="1"/></td>
<td style="height: 30px"> </td>
<td style="height: 30px"> </td>
</tr>
<tr>
<td style="height: 30px">Password:</td>
<td style="height: 30px">
<input name="passwd1" type="password" id="passwd1" class="reqd" tabindex="2"/></td>
<td style="height: 30px">Verify Password:</td>
<td style="height: 30px">
<input name="passwd2" type="password" id="passwd2" class="reqd" tabindex="3" /></td>
</tr>
<tr>
<td style="height: 18px" colspan="4">
<img alt="" src="images/line.png" width="515" height="5" /></td>
</tr>
<tr>
<td style="height: 30px">First Name:</td>
<td style="height: 30px"><input name="fname" type="text" class="reqd" tabindex="4" /></td>
<td style="height: 30px">Topic of Interest:</td>
<td style="height: 30px">
<input name="interest" type="text" class="reqd" tabindex="7" /></td>
</tr>
<tr>
<td style="height: 30px">Last Name:</td>
<td style="height: 30px"><input name="lname" type="text" class="reqd" tabindex="5" /></td>
<td style="height: 30px">Favorite Food:</td>
<td style="height: 30px">
<input name="food" type="text" class="reqd" tabindex="8" /></td>
</tr>
<tr>
<td style="height: 30px">E-mail Address:</td>
<td style="height: 30px">
<input name="email" type="text" class="reqd" tabindex="6" /></td>
<td style="height: 30px">Favorite Sport:</td>
<td style="height: 30px"><input name="sport" type="text" class="reqd" tabindex="9" /></td>
</tr>
<tr>
<td style="height: 25px" valign="top"> </td>
<td> </td>
<td> </td>
<td style="height: 30px">
<input name="Submit" type="submit" value="submit" tabindex="10" /> </td>
</tr>
</table>
</form>
</body>
</html>
any help would be great
Reply With Quote