SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Validation help

  1. #1
    SitePoint Member
    Join Date
    Oct 2006
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Validation help

    Hi,

    I have a form that utilizes validation as most do via javascript. This form worked totaly fine until I needed to add a dynamic div now the validation doesn't work. It does work for the first dropdown but nothing there after. I always get the error saying [form object] is null or not an object. I need help trying to figure out how to access the ojects in this form.

    Now in my body I have a <form> and it's name is form1 and I also have another <form> around a drop down and it's name is change and it closes right after the drop down. I don't want to put all of the code here because it's lengthy but I'll put some of it here so that someone can help me figure out what's going on.

    Code:
    <script>
    <!--
    function validate()
    {
    
    //check to see if the drop down was selected.
    
    len = document.form1.program.length;
    //alert(document.graderrors.school.length);
    i = 0;
    chosen = "none";
    
    for (i = 0; i < len; i++) 
    {
    	if (document.form1.program[i].selected)
    	{
    		
    		chosen = document.form1.program[i].value
    		//alert(document.graderrors.school[i].value);
    	} 
    }
    	if (chosen == "" || chosen==0 || chosen=="none") 
    	{
    		alert('Please select your program of study');
    		return false;
    	}
    
    
    
    //Check for errors
    if(window.document.form1.firstname.value=='')
    {
    		alert('Please fill out the First Name field');
    		window.document.form1.firstname.focus();
    		return false;
    } 
    else if(window.document.form1.lastname.value=='')
    {
    	alert('Please fill out the Last Name field.');
    	window.document.form1.lastname.focus();
    	return false;
    } 
    
    ....on and on with validation now on to some of the body
    
    <body bgcolor="#000000" topmargin="0" leftmargin="0" onLoad="javascript:hide();">
    <table align="center" border="0" bgcolor="#DDE324" cellspacing="0" cellpadding="0">
    <tr>
    <td bgcolor="#20249C">
    <table border="0" cellspacing="0" cellpadding="0">
    <tr>
    <td align="center" valign="top" height="31" bgcolor="#20249C">
    <p><img border="0" src="images/eCampuslgnew.jpg" alt="Keiser University eCampus Distance Education" width="693" height="85"><br>
    <font face="Verdana" size="1" color="#FFFFFF">Keiser University eCampus is the online division of Keiser University, Fort Lauderdale campus</font><b><font color="#FFFFFF" face="Verdana"><br></font> <font color="#EEEAB9" face="Verdana">Keiser University Division of Online Education Inquiry
    Form</font><font color="#FFFFFF" face="Verdana"><br></font></b> <font size="2" color="#EEEAB9" face="Verdana">To have an Admissions Counselor contact you, please fill out the form below</font></p>
    </td>
    </tr>
    </table>
    <form name="form1" method="post" action="process_ecampus_inquiry.php">
    <input type="hidden" name="type" value="KU Website">
    <table border="1" cellpadding="0" cellspacing="0" bordercolor="#20249C" width="691" id="table1">
    <tr>
    <td bgcolor="#20249C" width="155"></td>
    <td bgcolor="#20249C"><span class="style19">*indicates required field</span></td>
    </tr>
    <tr bgcolor="#DCDCDC">
    <td valign="top" nowrap="nowrap" align="right" width="155"><span class="style21"><font size="1">Program of Study*</font></span></td>
    <td nowrap="nowrap" width="530">
    <form name="change"><span class="style21"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><select id="program" tabindex="2" onChange="reveal(this.value);" name="program">
    <option value="">Select A Program...</option>
    <option value="">+ Master's Degrees</option>
    
    <option value="MBA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Master's in Business Administration</option>
    <option value="">+ Bachelor Degrees</option>
    <option value="ACCBA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Accounting, BA</option>
    <option value="BABA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Business Administration, BA - Management</option>
    <option value="BABA-FIN">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Business Administration, BA - Finance</option>
    <option value="BABA-HRM">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Business Administration, BA - Human Resources</option>
    
    <option value="BABA-IBT">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Business Administration, BA - Intl. Business</option>
    <option value="BABA-MKT">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Business Administration, BA - Marketing</option>
    <option value="BACJ">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Criminal Justice, BA</option>
    <option value="BAHSA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Health Services Administration, BA</option>
    <option value="BSHS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Health Science, BS</option>
    <option value="BAHS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Homeland Security, BA</option>
    
    <option value="BSITM">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Information Technology Management, BS</option>
    <option value="BALS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Legal Studies, BA</option>
    <option value="MISBA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Management Information Systems (MIS), BS</option>
    <option value="BSN">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Nursing, RN to BSN</option>
    <option value="" selected="selected">+ Associate Degrees</option>
    <option value="ACCAS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Accounting, AA</option>
    
    <option value="CJAA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Criminal Justice, AA</option>
    <option value="ITAS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Information Technology, AS</option>
    <option value="HSAAA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Health Services Administration, AA</option>
    <option value="HS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Homeland Security, AA</option>
    <option value="MAAS">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Medical Assisting, AS</option>
    <option value="PLAA">&nbsp;&nbsp;&nbsp;&nbsp;--&nbsp;Paralegal Studies, AA</option>
    
    </select></font></span></form>
    
    Now this is the div in case this is need for whatever reason
    
    <div id="realtooltip" style="display: inline">
    <table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#20249C" bgcolor="#DCDCDC" id="table2">
    <tbody>
    <tr>
    <td align="middle" bgcolor="white" colspan="2">
    <div align="center" class="style24"><span class="style23"><strong><font size="2">Must be a U.S. licensed RN to qualify for our nursing program.</font></strong><font size="2"><br>
    <span class="style1">Please answer the following if you are interested in our Bachelor of Science in Nursing program.</span><br>
    <br>
    Nursing Prerequisites</font></span></div>
    </td>
    </tr>
    <tr>
    
    <td></td>
    <td nowrap="nowrap" width="100%"></td>
    </tr>
    <tr>
    <td colspan="2">
    <table width="350" border="0" id="table3">
    <tbody>
    <tr>
    <td><span class="style21"><font size="1">Do you possess a current, unrestricted license to practice as a registered nurse in at least one U.S. state, including the state in which a clinical will be completed?</font></span></td>
    <td valign="top" nowrap="nowrap"><span class="style21"><font size="1">&nbsp;&nbsp;</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="licensed" type="hidden" name="licensed"></font></span>
    <table width="138" border="0" cellspacing="0" cellpadding="0" id="table4">
    <tr>
    <td width="47"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="radio" onClick="form.licensed.checked=false;form.licensed.value='yes';" type="radio" value="yes" name="licensed"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">yes&nbsp;</font></td>
    
    <td width="27"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="radio2" onClick="form.licensed.checked=false;form.licensed.value='no';" type="radio" value="no" name="licensed"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">no</font></td>
    </tr>
    </table>
    <span class="style21"><font size="1">&nbsp;</font></span></td>
    </tr>
    <tr>
    <td><span class="style21"><font size="1">Are you a graduate of an associate degree program or a diploma nursing program?</font></span></td>
    <td valign="top" nowrap="nowrap"><span class="style21"><font size="1">&nbsp;&nbsp;</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="gpa" type="hidden" name="gpa"></font></span>
    <table width="138" border="0" cellspacing="0" cellpadding="0" id="table5">
    <tr>
    <td width="47"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="radio3" onClick="form.gpa.value='yes';form.gpa.checked=false;" tabindex="30" type="radio" value="yes" name="gpa"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">yes&nbsp;</font></td>
    
    <td width="27"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="radio4" onClick="form.gpa.value='no';form.gpa.checked=false;" tabindex="31" type="radio" value="no" name="gpa"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">no</font></td>
    </tr>
    </table>
    </td>
    </tr>
    <tr>
    <td><span class="style21"><font size="1">Are you a U.S. citizen or a national or permanent resident of the U.S.?</font></span></td>
    <td valign="top" nowrap="nowrap"><span class="style21"><font size="1">&nbsp;&nbsp;</font> <font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="uscitizen" type="hidden" name="uscitizen"></font></span>
    <table width="138" border="0" cellspacing="0" cellpadding="0" id="table6">
    <tr>
    <td width="47"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input onClick="form.uscitizen.value='yes';form.uscitizen.checked=false;" tabindex="32" type="radio" value="yes" name="uscitizen"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">yes&nbsp;</font></td>
    
    <td width="27"><font size="1" face="Verdana, Arial, Helvetica, sans-serif"><input id="radio5" onClick="form.uscitizen.value='no';form.uscitizen.checked=false;" tabindex="33" type="radio" value="no" name="uscitizen"></font></td>
    <td width="32"><font size="1" face="Verdana, Arial, Helvetica, sans-serif">no</font></td>
    </tr>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    </td>
    </tr>
    </tbody>
    </table>
    <layer></layer>
    </div>

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,035
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)

    form tags

    I only see 1 closing form tag. If it comes after the code you posted, AFAIK, you can't nest a form inside of another form.

  3. #3
    SitePoint Enthusiast
    Join Date
    May 2005
    Posts
    27
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nest form tags are not allowed by HTML specifications.

    And having nested tags makes JavaScript code stop working. I had that bug a few times


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •