I have the following files:

1. a PHP page that is loaded first and includes a number of functions. It calls a couple of other pages:

1a. a template file that has the following function in the head:

function checkForm( what )
{
        var ret = false;

        if( isBlank( document.getElementById('firstname') ) ) {
                alert( 'You must enter your first name' );
        } else if( isBlank( document.getElementById('surname') ) ) {
                alert( 'You must enter your last name' );
        } else if( isBlank( document.getElementById('agency') ) ) {
                alert( 'You must enter your school or agency' );
        } else if( isBlank( document.getElementById('email') ) ) {
                alert( 'You must enter your e-mail address' );
		 } else if( !isBlank( document.getElementById('partnerLast') && isBlank(document.getElementById('partM') ) ) {
                alert( 'You must enter your partner\'s birthday' );
        } else if( isBlank( document.getElementById('address1') ) ) {
                alert( 'You must enter your mailing address' );
        } else if( isBlank( document.getElementById('city') ) ) {
                alert( 'You must enter your city' );
        } else if( isBlank( document.getElementById('pcode') ) ) {
                alert( 'You must enter your postal code' );
        } else if( isBlank( document.getElementById('acode') ) || isBlank( document.getElementById('tela') ) || isBlank( document.getElementById('telb') ) ) {
                alert( 'You must enter your telephone number' );
        } else if( checkGroup(what.category) == null ) {
                alert( 'You must select a category' );
        } else {
                ret = true;
        }

        return ret;
}

1b: a php file that represents step one of a four part form.

In the file from 1b, I have the following code:

function so_FormRow( $text, $required, $name, $size, $verify = null ) {
	$ret = '<tr><td style="text-align: right;">';
	if( $required ) {
		$ret .= '<span class="required">*</span> ';
	}
	$ret .= $text;
	$ret .= '</td><td><input ';
	if( $verify != null ) {
		$ret .= 'onblur="'.$verify.'(this);" ';
	}
	$ret .= 'name="'.$name.'" class="entryFormFields" id="'.$name.'" size="'.$size.'"';
	if( isset( $_COOKIE['naa'][$name] ) ) {
		$ret .= ' value="'.$_COOKIE['naa'][$name].'"';
	}
	$ret .= '></td></tr>';

	return $ret;
}

and

<form method="post" onSubmit="return checkForm(this);">
<table width="500" border="0" cellpadding="3" class="entryform">
<tr class="miniheading">
	<td colspan="2" class="boldbody" style="padding: 3px;">Your Information</td>
</tr>
EOF;

$ccContent .= so_FormRow( "First Name", true, 'firstname', 30, 'checkBlank' ).
              so_FormRow( "Last Name", true, 'surname', 30, 'checkBlank' ).
	      so_FormRow( "School/Agency", true, 'agency', 30, 'checkBlank' ).
	      so_FormRow( "Province", true, 'prov', 30, 'checkBlank' ).
	      '<tr><td style="text-align: right; vertical-align: top;"><span class="required">*</span> Birthday</td>'.
	      '<td>'.
	      so_Months( "entM" ).' '.so_Days( "entD" ).' '.so_Years( "entY" ).
	      '<br/><span class="mainbody2"></span>'.
	      '</td></tr>'.
	      so_FormRow( "E-mail Address", true, 'email', 30 ).
	      "<tr class=\"miniheading\"><td colspan=\"2\" style=\"padding: 3px;\">Your Partner's Information (if applicable)</td></tr>".
	      so_FormRow( "Partner's First Name", false, 'partnerFirst', 30 ).
	      so_FormRow( "Partner's Last Name", false, 'partnerLast', 30 ).
	      so_FormRow( "School or Agency", false, 'partnerAgency', 30 ).
	      so_FormRow( "Province", false, 'partnerProv', 30 ).
	      "<tr><td style=\"text-align: right; vertical-align: top;\"><span class=\"required\">*</span> Partner's Birthday</td>".
	      '<td>'.
	      so_Months( "partM" ).' '.so_Days( "partD" ).' '.so_Years( "partY" ).
	      '<br/><span class="mainbody2"></span>'.
	      so_FormRow( "Email", false, 'partnerEmail', 30 );

$ccContent .= <<<EOF

So, what is supposed to happen is that when one of the form fields in this section is not filled out, an alert window is supposed to come up. This used to work but I moved to a new server, and of course, now it does not. I have looked at this for a while now but can't seem to find it so perhaps a fresh pair of eyes will see it.

I appreciate the help.

Dave

Could you post how the form is displayed within the source code, due to the fact that it would be easier to test the javascript code for ourselves.

~G

Could you post how the form is displayed within the source code, due to the fact that it would be easier to test the javascript code for ourselves.

~G

I assume you are referring to generated code. It is a lot of code, which is why I did not post it all before. Below is the bulk of the generated page, with some of the non-essential stuff taken out. Please excuse the shoddy HTML as this is an old page that the client does not want to update for cost reasons.

<html xmlns="http://www.w3.org/1999/xhtml"><head><!-- <link href="../assets/css/cc.css" rel="stylesheet" type="text/css" /> -->



<!-- TemplateBeginEditable name="doctitle" -->
<title>National Advertising Awards | welcome</title>
<!-- TemplateEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="generator" content="DWMX">
<link rel="shortcut icon" href="/favicon.ico">
<script type="text/javascript">
function checkBlank( what )
{
        if( what.value.length == 0 ) {
                alert( 'This field cannot be left blank' );
                return true;
        }

        return false;
}

function isBlank( what )
{
        if( what.value == "" ) {
                return true;
        }

        return false;
}

function isInteger( val )
{
        if( isBlank(val) ) { return false; }
        for( var i=0;i<val.length;i++ ) {
                if( !isDigit(val.charAt(i)) ) { return false; }
        }
        return true;
}

function checkDigits( what, num )
{
        if( checkBlank( what ) ) {
                if( what.value.length != num ) {
                        alert( 'This field must contain ' + num + ' numbers.' );
                        what.focus();
                        return false;
                } else if( !isInteger( what ) ) {
                        alert( 'This field must only contain numbers.' );
                        what.focus();
                        return false;
                }
        }
}

function checkEmail( what )
{
        if( checkBlank( what ) ) {
                if ( what.value.indexOf('@') && (what.value.indexOf('@')+1 < what.value.length) ) {
                        return true;
                } else {
                        alert( "Please enter a valid E-Mail address" );
                        what.focus();
                        return false;
                }
        }
}

function checkGroup( what )
{
        var x = -1;
        for( var y=what.length-1;y>-1;y-- ) {
                if( what[y].checked ) {
                        x = y;
                        y = -1;
                }
        }

        if( x > -1 ) {
                return what[x].value;
        } else {
                return null;
        }
}

function checkForm( what )
{
        var ret = false;

        if( isBlank( document.getElementById('firstname') ) ) {
                alert( 'You must enter your first name' );
        } else if( isBlank( document.getElementById('surname') ) ) {
                alert( 'You must enter your last name' );
        } else if( isBlank( document.getElementById('agency') ) ) {
                alert( 'You must enter your school or agency' );
        } else if( isBlank( document.getElementById('email') ) ) {
                alert( 'You must enter your e-mail address' );
		 } else if( !isBlank( document.getElementById('partnerLast') && isBlank(document.getElementById('partM') ) ) {
                alert( 'You must enter your partner\'s birthday' );
        } else if( isBlank( document.getElementById('address1') ) ) {
                alert( 'You must enter your mailing address' );
        } else if( isBlank( document.getElementById('city') ) ) {
                alert( 'You must enter your city' );
        } else if( isBlank( document.getElementById('pcode') ) ) {
                alert( 'You must enter your postal code' );
        } else if( isBlank( document.getElementById('acode') ) || isBlank( document.getElementById('tela') ) || isBlank( document.getElementById('telb') ) ) {
                alert( 'You must enter your telephone number' );
        } else if( checkGroup(what.category) == null ) {
                alert( 'You must select a category' );
        } else {
                ret = true;
        }

        return ret;
}

function doProgressWin( utxt )
{
        if( utxt.indexOf('/') > -1 )
                tf = utxt.substring(utxt.lastIndexOf('/')+1,utxt.length );
        else
                tf = utxt.substring(utxt.lastIndexOf('\\')+1,utxt.length );

        child_window = window.open( 'http://entry.nationaladvertisingawards.ca/cgi-bin/upprog.cgi?t='+tf,'upwin','menubar=0,resizable=0,width=400,height=200,scrollbars=0,status=0,location=0,toolbar=0,directories=0' );

        child_window.focus();
}

var child_window = null;

function checkChild()
{
        if( child_window != null )
                child_window.focus();
}

//-->
</script>

<script type="text/javascript" src="../p7pm/p7popmenu.js"></script><style type="text/css">
#p7PMnav ul {position:absolute;left:-9000px;}
#p7PMnav ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}
#p7PMnav ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul ul {position:absolute;left:-9000px;}

</style>
<style type="text/css" media="screen">
<!--
@import url("../p7pm/p7pmh0.css");
-->
</style>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<link href="/assets/css/naa_2008_form.css" rel="stylesheet" type="text/css" media="screen">
</head><body onload="P7_initPM(1,0,0,-20,10)">
<div id="container">
  <div id="header">
    <h1 id="header"><a href="/index.htm" class="nohover"><img src="/assets/images/global/clear.gif" alt="National Advertising Awards" border="0" width="800" height="100"></a></h1>
  </div>
  <div id="nav-container">
    <div id="menu">

      <ul id="p7PMnav">
        <li><a href="/categories/index.htm" class="p7PMtrg">BRIEFS</a>
            <ul>
              <li><a href="#">DIRECT</a></li>
              <li><a href="#">FILM</a></li>
              <li><a href="#">VIDEO</a></li>
              <li><a href="#">INTERACTIVE</a></li>

              <li><a href="#">YOUNG CREATIVES</a></li>
              <li><a href="#">YOUNG MEDIA</a></li>
            </ul>
        </li>
        <li><a href="#">HOW TO ENTER</a></li>
        <li><a href="#">JUDGES</a></li>
        <li><a href="#">PAST WINNERS</a></li>

        <!--[if lte IE 6]><style>#p7PMnav a{height:1em;}#p7PMnav li{height:1em;}#p7PMnav ul li{float:left;clear:both;width:100%}</style><![endif]-->
        <!--[if IE 6]><style>#p7PMnav ul li{clear:none;}</style><![endif]-->
        <!--[if IE 7]><style>#p7PMnav a{zoom:100%;}#p7PMnav ul li{float:left;clear:both;width:100%;}</style><![endif]-->
      </ul>
    </div>
  </div>
 <div id="wrapper">
    <div id="content"> <!-- TemplateBeginEditable name="titlegraphic" -->

      
      <!-- TemplateEndEditable --> <!-- TemplateBeginEditable name="breadnav" --><p class="breadcrumb"><a href="/index.htm">home</a> / <a href="/categories/index.htm">categories</a> / young media</p><!-- TemplateEndEditable --> <!-- TemplateBeginEditable name="pagetitle" --><img src="/assets/images/global/title-entry.gif">
     
      <!-- TemplateEndEditable --> <!-- TemplateBeginEditable name="main_content" -->
      
<center><table style="width: 600px; height: 75px;" cellpadding="0" cellspacing="0"><tbody><tr><td style="margin: 0px; padding: 0px; height: 90px; text-align: center;" width="25%"><font color="#800000" face="Impact;Helvetica" size="+4"><b style="line-height: 1em; height: 75px;">1</b></font><br>information</td><td style="margin: 0px; padding: 0px; height: 90px; text-align: center;" width="25%"><font color="#666666" face="Impact;Helvetica" size="+4"><b style="line-height: 1em; height: 75px;">2</b></font><br>confirm</td><td style="margin: 0px; padding: 0px; height: 90px; text-align: center;" width="25%"><font color="#666666" face="Impact;Helvetica" size="+4"><b style="line-height: 1em; height: 75px;">3</b></font><br>file upload</td><td style="margin: 0px; padding: 0px; height: 90px; text-align: center;" width="25%"><font color="#666666" face="Impact;Helvetica" size="+4"><b style="line-height: 1em; height: 75px;">4</b></font><br>confirmation</td></tr></tbody></table></center><br>

<h1>Entry Form - Part One</h1>
<br>
<h2><em>Entering is a four-part process.</em></h2><em></em><br>
<p>A separate entry form must be filled out for <span class="boldbody">each</span> submission. For example, if you are YC or All Ages entering 2 ideas in Press and 2 ideas in Out of Home, you will need to fill out this entry form <span class="boldbody">four</span> times.  This is important so that you get a unique ID number for each submission.</p>
<h2><em>The Entry Process</em></h2>
<ol class="mainbody">

<li>Fill out your contact information using the form below.<br>
<dd>(Fields marked with a <span class="required">*</span> are mandatory)
</dd></li><li>On the next page, select the file you wish to upload.  <em>Make sure</em> the file relates to the category you are entering, particularly if you are entering multiple times and/or multiple categories.
</li><li>The confirmation page will be displayed after your file has been uploaded.  Print this page and mail, courier or bring in your hard copies no later than 5:30pm on Monday, March 30 (Monday April 6 for Young Media category).


<center>
<form method="post" onsubmit="return checkForm(this);">
<table class="entryform" border="0" cellpadding="3" width="500">
<tbody><tr class="miniheading">
	<td colspan="2" class="boldbody" style="padding: 3px;">Your Information</td>

</tr><tr><td style="text-align: right;"><span class="required">*</span> First Name</td><td><input onblur="checkBlank(this);" name="firstname" class="entryFormFields" id="firstname" size="30"></td></tr><tr><td style="text-align: right;"><span class="required">*</span> Last Name</td><td><input onblur="checkBlank(this);" name="surname" class="entryFormFields" id="surname" size="30"></td></tr><tr><td style="text-align: right;"><span class="required">*</span> School/Agency</td><td><input onblur="checkBlank(this);" name="agency" class="entryFormFields" id="agency" size="30"></td></tr><tr><td style="text-align: right;"><span class="required">*</span> Province</td><td><input onblur="checkBlank(this);" name="prov" class="entryFormFields" id="prov" size="30"></td></tr><tr><td style="text-align: right; vertical-align: top;"><span class="required">*</span> Birthday</td><td><select name="entM" class="entryFormFields"><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select> <select name="" entd="" class="entryFormFields"><option> 1</option><option> 2</option><option> 3</option><option> 4</option><option> 5</option><option> 6</option><option> 7</option><option> 8</option><option> 9</option><option> 10</option><option> 11</option><option> 12</option><option> 13</option><option> 14</option><option> 15</option><option> 16</option><option> 17</option><option> 18</option><option> 19</option><option> 20</option><option> 21</option><option> 22</option><option> 23</option><option> 24</option><option> 25</option><option> 26</option><option> 27</option><option> 28</option><option> 29</option><option> 30</option><option> 31</option></select> <select name="entY" class="entryFormFields"><option>1950</option><option>1951</option><option>1952</option><option>1953</option><option>1954</option><option>1955</option><option>1956</option><option>1957</option><option>1958</option><option>1959</option><option>1960</option><option>1961</option><option>1962</option><option>1963</option><option>1964</option><option>1965</option><option>1966</option><option>1967</option><option>1968</option><option>1969</option><option>1970</option><option>1971</option><option>1972</option><option>1973</option><option>1974</option><option>1975</option><option>1976</option><option>1977</option><option>1978</option><option>1979</option><option>1980</option><option>1981</option><option>1982</option><option>1983</option><option>1984</option><option>1985</option><option>1986</option><option>1987</option><option>1988</option><option>1989</option><option>1990</option><option>1991</option><option>1992</option><option>1993</option><option>1994</option><option>1995</option><option>1996</option><option>1997</option><option>1998</option><option>1999</option><option>2000</option><option>2001</option><option>2002</option><option>2003</option><option>2004</option><option>2005</option><option>2006</option><option>2007</option><option>2008</option><option>2009</option><option>2010</option></select><br><span class="mainbody2"></span></td></tr><tr><td style="text-align: right;"><span class="required">*</span> E-mail Address</td><td><input name="email" class="entryFormFields" id="email" size="30"></td></tr><tr class="miniheading"><td colspan="2" style="padding: 3px;">Your Partner's Information (if applicable)</td></tr><tr><td style="text-align: right;">Partner's First Name</td><td><input name="partnerFirst" class="entryFormFields" id="partnerFirst" size="30"></td></tr><tr><td style="text-align: right;">Partner's Last Name</td><td><input name="partnerLast" class="entryFormFields" id="partnerLast" size="30"></td></tr><tr><td style="text-align: right;">School or Agency</td><td><input name="partnerAgency" class="entryFormFields" id="partnerAgency" size="30"></td></tr><tr><td style="text-align: right;">Province</td><td><input name="partnerProv" class="entryFormFields" id="partnerProv" size="30"></td></tr><tr><td style="text-align: right; vertical-align: top;"><span class="required">*</span> Partner's Birthday</td><td><select name="partM" class="entryFormFields"><option value="1">January</option><option value="2">February</option><option value="3">March</option><option value="4">April</option><option value="5">May</option><option value="6">June</option><option value="7">July</option><option value="8">August</option><option value="9">September</option><option value="10">October</option><option value="11">November</option><option value="12">December</option></select> <select name="" partd="" class="entryFormFields"><option> 1</option><option> 2</option><option> 3</option><option> 4</option><option> 5</option><option> 6</option><option> 7</option><option> 8</option><option> 9</option><option> 10</option><option> 11</option><option> 12</option><option> 13</option><option> 14</option><option> 15</option><option> 16</option><option> 17</option><option> 18</option><option> 19</option><option> 20</option><option> 21</option><option> 22</option><option> 23</option><option> 24</option><option> 25</option><option> 26</option><option> 27</option><option> 28</option><option> 29</option><option> 30</option><option> 31</option></select> <select name="partY" class="entryFormFields"><option>1950</option><option>1951</option><option>1952</option><option>1953</option><option>1954</option><option>1955</option><option>1956</option><option>1957</option><option>1958</option><option>1959</option><option>1960</option><option>1961</option><option>1962</option><option>1963</option><option>1964</option><option>1965</option><option>1966</option><option>1967</option><option>1968</option><option>1969</option><option>1970</option><option>1971</option><option>1972</option><option>1973</option><option>1974</option><option>1975</option><option>1976</option><option>1977</option><option>1978</option><option>1979</option><option>1980</option><option>1981</option><option>1982</option><option>1983</option><option>1984</option><option>1985</option><option>1986</option><option>1987</option><option>1988</option><option>1989</option><option>1990</option><option>1991</option><option>1992</option><option>1993</option><option>1994</option><option>1995</option><option>1996</option><option>1997</option><option>1998</option><option>1999</option><option>2000</option><option>2001</option><option>2002</option><option>2003</option><option>2004</option><option>2005</option><option>2006</option><option>2007</option><option>2008</option><option>2009</option><option>2010</option></select><br><span class="mainbody2"></span></td></tr><tr><td style="text-align: right;">Email</td><td><input name="partnerEmail" class="entryFormFields" id="partnerEmail" size="30"></td></tr>

<tr class="miniheading">
	<td colspan="2">Category</td>
</tr><tr>
	<td colspan="2" style="text-align: center;">
	<table style="border: 0px none ;" cellpadding="0" cellspacing="0" width="100%">
	  <tbody><tr class="miniheading02">
	    <td class="mainbody_2008" valign="top">ALL AGES</td>
	    <td class="mainbody_2008">YOUNG CREATIVES (28 and Under)</td>

	    </tr>
	  <tr>
	<td class="mainbody_2008" valign="top">
		<label><input id="cat" name="category" value="DIR" type="radio"> Direct</label><br>
		<label><input id="cat" name="category" value="INT" type="radio"> Integrated</label><br>
		<label><input id="cat" name="category" value="MOB" type="radio"> Mobile</label><br>

		<label><input id="cat" name="category" value="AIN" type="radio"> Interactive</label><br>
        <label><input id="cat" name="category" value="OOH" type="radio"> Out-of-Home</label><br>
		<label><input id="cat" name="category" value="PRN" type="radio"> Print</label><br>
		</td>
        <td class="mainbody_2008" valign="top">
		<label><input id="cat" name="category" value="YPO" type="radio"> Young Creatives</label><br>	
	</td>

	</tr>
	<tr class="miniheading02">
	<td colspan="2" valign="top">YOUNG MEDIA (30 and Under)</td></tr>
	<tr><td colspan="2" class="mainbody_2008" valign="top"><label><input id="cat" name="category" value="YMC" type="radio"> Young Media</label><br></td></tr></tbody></table>
	</td>
</tr><tr class="miniheading">
	<td colspan="2" class="boldbody" style="padding: 3px;">Contact Information</td>

</tr><tr><td style="text-align: right;"><span class="required">*</span> Mailing Address</td><td><input name="address1" class="entryFormFields" id="address1" size="30"></td></tr><tr><td style="text-align: right;">&nbsp;</td><td><input name="address2" class="entryFormFields" id="address2" size="30"></td></tr><tr><td style="text-align: right;"><span class="required">*</span> City</td><td><input name="city" class="entryFormFields" id="city" size="30"></td></tr><tr><td style="text-align: right;"><span class="required">*</span> Postal Code</td><td><input name="pcode" class="entryFormFields" id="pcode" size="11"></td></tr><tr><td class="mainbody2" style="text-align: right;"><span class="required">*</span> Phone:</td><td color="#ffffff">(<input onblur="checkDigits(this,3);" name="acode" id="acode" class="entryFormFields" size="3" maxlength="3">) <input onblur="checkDigits( this, 3 );" name="tela" class="entryFormFields" id="tela" size="3" maxlength="3" type="text"> - <input onblur="checkDigits( this, 4 );" name="telb" class="entryFormFields" id="telb" size="4" maxlength="4" type="text"></td></tr><tr><td colspan="2" class="boldbody">

</td></tr><tr>
	<td><input value="Clear" type="Reset"></td>
	<td style="text-align: right;"><input value="Next &gt;&gt;" type="Submit"></td>
</tr><tr>
<td colspan="2"><br>
</td></tr>
</tbody></table>
<input name="step" value="2" type="hidden">
</form>

</center>
   
    <!-- TemplateEndEditable -->
    </div>
   
   <div id="footer">

      </div> 
 </div>
  
</div>

</body></html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.