Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Form validation help

Status
Not open for further replies.

teksmile

Programmer
May 13, 2008
3
US
Hi there:

I have this function which validates chosend fields from the form and gives the alert poop up box on submission listing which all fields were not filled.

But for some reason...even after leaving al the fields blank..i am not getting any pop up box...here is my function:
function validateForm()
{
var count=0;
var msg="";
var ele = new Array();
ele[0]="firstname";
ele[1]="lastname";
ele[2]="address1";
ele[3]="city";
ele[4]="state";
ele[5]="zip";
ele[6]="email";
ele[7]="dayphone";
ele[8]="programofinterest";
ele[9]="campus";
ele[10]="todo";
ele[11]="hsdiploma";
ele[12]="yearofhs";
ele[13]="ged";
ele[14]="yearofgrad";
ele[15]="leadsource";

for(i=0;i<ele.length;i++)
{
if(document.contact.ele.value=="")
{
count=1;
msg=msg+"\n"+document.contact.ele.name;
}
else if((i>ele.length) && (count==0))
{
return(true);
}
}
for(i=0;i<ele.length;i++)
{
if(document.contact.ele.value=="")
{
alert("PLEASE FILL IN THE FOLLOWING FIELD(S)\n "+msg);
document.contact.ele.focus();
return(false);
}

}

}
 
Where's your HTML? You need to learn to indent your code so it's easier to read, too.

Code:
var missing = -1;
for(i = ele.length - 1; i >- 0; i++)
{
  if(document.contact.ele[i].value=="")
  {
    msg=msg+"\n"+document.contact.ele[i].name;
    missing = i;
  }
}

if (msg.length == 0)
{
  return true;
}

alert("PLEASE FILL IN THE FOLLOWING FIELD(S)\n "+msg);
document.contact.ele[missing].focus();
return false;
}

Lee
 
I tried your code..but no luck i still dont get the popup.
What must be wrong????I am so confused
 
sorry ..this is the whole code:

Code:
this is the whole code:

[code]
<?php

function show_page($message=null, $sendSuccess=null) {

header('Location: /thank-you');

}

function error_bool($error, $field) {
         if($error[$field]) {
             print("class=\"error\"");
         }
        else {
             print("class=\"normal\"");
        }
    }
	
function error_selectone($error, $field) {
         if($error[$field]) {
             print("class=\"error2\"");
         }
        else {
            print("class=\"selectone\"");
        }
    }

function show_form($message=null) {
global $HTTP_POST_VARS, $print_again, $error;
$gradyear = "none";
$gedfield = "none";
$stillattend = "none";

$tour = "";

if($_GET['type']=="tour")
{

   $tour=" checked";
}

?>
<h1><?php if($_REQUEST['type']=='tour'){ ?>Schedule a Tour<?php }else{ ?>
Request More Info<?php } ?></h1>

<?php if($sendSuccess == true){ ?>
	Your information has been sent to the appropriate campus.
<?php }else{ ?>
<p>Thank you for your interest in one of our Lincoln Educational Services Schools. Please complete the form below and a Career Advisor will contact you to:</p>
<ul>
<li>Answer your questions regarding any of the programs</li>
<li>Provide information and application materials based on your specific needs and goals</li>
</ul>
</p>
<?php } ?>

<h2>Start Your Future. Now.</h2>
<p class="required">Required*<br/>
<?=$message?></p>
<script type="text/javascript">
function validate() {
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var addres = document.contact.email.value;
   
   if(reg.test(addres) == false) {
      alert('Invalid Email Address');
      return false;
   

   }


}
function validateForm()
{
var count=0;
var msg="";
var ele = new Array();
ele[0]="firstname";
ele[1]="lastname";
ele[2]="address1";
ele[3]="city";
ele[4]="state";
ele[5]="zip";
ele[6]="email";
ele[7]="dayphone";
ele[8]="programofinterest";
ele[9]="campus";
ele[10]="todo";
ele[11]="hsdiploma";
ele[12]="yearofhs";
ele[13]="ged";
ele[14]="yearofgrad";
ele[15]="leadsource";
var missing = -1;
for(i = ele.length - 1; i >- 0; i++)
{
  if(document.contact.ele[i].value=="")
  {
    msg=msg+"\n"+document.contact.ele[i].name;
    missing = i;
  }
}

if (msg.length == 0)
{
  return true;
}

alert("PLEASE FILL IN THE FOLLOWING FIELD(S)\n "+msg);
document.contact.ele[missing].focus();
return false;
}
    
   
}


</script>
<form action="" method="post" name="contact" id="contact" onsubmit="javascript:return validateForm();">

<fieldset class="type-a">	
<label <?php error_bool($error, "firstname");?>> First Name<span class="required">*</span>
<input name="firstname" type="text" id="name" value="<? echo $_POST["firstname"];?>"></label>

<label <?php error_bool($error, "lastname");?> > Last Name<span class="required">*</span>
<input name="lastname" type="text" id="lastname" value="<? echo $_POST["lastname"];?>"></label>

<label <?php error_bool($error, "address1");?> > Address<span class="required">*</span>
<input name="address1" type="text" id="lastname2" value="<? echo $_POST["address1"];?>"></label>

<label <?php error_bool($error, "city");?> > City<span class="required">*</span>
<input name="city" type="text" id="lastname" value="<? echo $_POST["city"];?>"></label>

<label <?php error_bool($error, "state");?> > State<span class="required">*</span>
    <select name="state">
    <option value="">---Select a State---</option>
    <?php 
			$result = mysql_query("SELECT * FROM les_states ORDER BY state ASC");
				
				while($states = mysql_fetch_array($result)) {
				
	?>
					<option value=<?=$states['state_abbr']?> <?php if($states['state_abbr']==$_POST['state']) {print "selected";}?>><?=$states['state']?></option>
    <?php } ?>
    </select>
    </label>


     <label <?php error_bool($error, "zip");?> > Zip Code<span class="required">*</span>
     <input name="zip" type="text" id="zip" value="<? echo $_POST["zip"];?>"></label>

</fieldset>


<fieldset class="type-a">

<label <?php error_bool($error, "dayphone");?> > Day Phone<span class="required">*</span>
<input type="text" name="dayphone" value="<? echo $_POST["dayphone"];?>"><br />(i.e. 212-555-1212)</label>

<label <?php error_bool($error, "cellphone");?> > Cell Phone 
<input name="cellphone" type="text" id="workphone" value="<? echo $_POST["cellphone"];?>"></label>

<label <?php error_bool($error, "workphone");?> > Work Phone 
<input name="workphone" type="text" id="workphone" value="<? echo $_POST["workphone"];?>"></label>
        
<label <?php error_bool($error, "email");?> > Email<span class="required">*</span>
<input name="email" type="text" id="email" value="<? echo $_POST["email"];?>"></label>
<label <?php error_bool($error, "confirmemail");?>>Retype Email<span class="required">*</span>
<input name="confirmemail" type="text" id="confirmemail" value="<? echo $_POST["confirmemail"];?>"><br /></label>
</fieldset>

<div class="separator">
<hr/>
</div>

<fieldset class="type-a">

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Program<span class="required">*</span></p> 
<select onChange="getCurrentOption(this);showElemById('campus-fields')" name="programofinterest" id="select-program" class="select-program">
<option value="">---------------------------Select A Program-----------------------</option>
<option value="">-------------------------ONLINE PROGRAMS------------------------</option>
<?php
$program_result = mysql_query("SELECT p.* , vp.* FROM les_programs AS p INNER JOIN les_verticals_programs AS vp WHERE p.cvcode = vp.cvcode AND program LIKE 'ONLINE%' ORDER BY p.cvcode") or die(mysql_error());


while($program_row = mysql_fetch_array($program_result)) { 

	$prglist = $program_row['program'];
	$vidlist = $program_row['vid'];
	$prgclass = strtolower($program_row['cvcode']);
	$prgURL = strtolower(str_replace(" ", "-", $prglist));
	echo "<option value=\"".$program_row['cvcode']."\" id=\"".$prgclass."\" ";	

	if($program_row['cvcode']==$_POST['programofinterest']){print "selected=\"selected\" ";}

	
	$vnamelist = mysql_query("SELECT vertical FROM les_verticals WHERE vid='".$vidlist."'");
	
	$result = mysql_query("SELECT lid FROM les_programs_locations WHERE cvcode='".$program_row['cvcode']."' ORDER BY lid");
	
//	$jsCampusList;
	
	while($vname = mysql_fetch_array($vnamelist)) {
	
		$vertical = strtolower(str_replace(" + ","-",$vname['vertical']));
                $vertical = strtolower(str_replace(" ","-",$vname['vertical']));
			
		while($row = mysql_fetch_array($result)){
			$lid_set = explode("|",$row['lid']);
			$fulLocStrg = array();
			foreach($lid_set as $lid){
				global $locClass;
				$locQuery = "SELECT * FROM les_locations WHERE lid LIKE '".$lid."'"; 
				$locResult = mysql_query($locQuery) or die(mysql_error());
				while($locRow = mysql_fetch_array($locResult)){
					$locCity = $locRow['city'];
					$locClass = strtolower(strtolower($locRow['state']).str_replace(" ", "", $locCity));
					
					$fulLocStrg[] = $locClass;
				}
			}
			
			sort($fulLocStrg);
			
			$outFulLocStrg = "";
			foreach($fulLocStrg as $alphaItem){
				$outFulLocStrg .= $alphaItem.",";
			}
			
			$outFulLocStrg = substr_replace($outFulLocStrg, '', -1, 1);
			
			echo 'class="'.$outFulLocStrg.'">';
		}
	}
	
	echo $prglist."</option>\n";


 
	

	if($_POST['programofinterest']=="[URL unfurl="true"]WWWMEDAS"){[/URL] 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('[URL unfurl="true"]wwwlline');}";[/URL]
	echo "</script>";
	}elseif($_POST['programofinterest']=="[URL unfurl="true"]WWWCRIMJUS"){[/URL] 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('[URL unfurl="true"]wwwlline');}";[/URL]
	echo "</script>";
	}elseif($program_row['cvcode']==$_POST['programofinterest']){ 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('".$outFulLocStrg."');}";
	echo "</script>";
	}
}
?>
<option value="">--------------------------CAMPUS PROGRAMS------------------------</option>; 
<?php
$program_result = mysql_query("SELECT p.* , vp.* FROM les_programs AS p INNER JOIN les_verticals_programs AS vp WHERE p.cvcode = vp.cvcode AND program NOT LIKE 'ONLINE%' ORDER BY p.cvcode") or die(mysql_error());


while($program_row = mysql_fetch_array($program_result)) { 

	$prglist = $program_row['program'];
	$vidlist = $program_row['vid'];
	$prgclass = strtolower($program_row['cvcode']);
	$prgURL = strtolower(str_replace(" ", "-", $prglist));
	echo "<option value=\"".$program_row['cvcode']."\" id=\"".$prgclass."\" ";	

	if($program_row['cvcode']==$_POST['programofinterest']){print "selected=\"selected\" ";}

	
	$vnamelist = mysql_query("SELECT vertical FROM les_verticals WHERE vid='".$vidlist."'");
	
	$result = mysql_query("SELECT lid FROM les_programs_locations WHERE cvcode='".$program_row['cvcode']."' ORDER BY lid");
	
//	$jsCampusList;
	
	while($vname = mysql_fetch_array($vnamelist)) {
	
		$vertical = strtolower(str_replace(" + ","-",$vname['vertical']));
                $vertical = strtolower(str_replace(" ","-",$vname['vertical']));
			
		while($row = mysql_fetch_array($result)){
			$lid_set = explode("|",$row['lid']);
			$fulLocStrg = array();
			foreach($lid_set as $lid){
				global $locClass;
				$locQuery = "SELECT * FROM les_locations WHERE lid LIKE '".$lid."'"; 
				$locResult = mysql_query($locQuery) or die(mysql_error());
				while($locRow = mysql_fetch_array($locResult)){
					$locCity = $locRow['city'];
					$locClass = strtolower(strtolower($locRow['state']).str_replace(" ", "", $locCity));
					
					$fulLocStrg[] = $locClass;
				}
			}
			
			sort($fulLocStrg);
			
			$outFulLocStrg = "";
			foreach($fulLocStrg as $alphaItem){
				$outFulLocStrg .= $alphaItem.",";
			}
			
			$outFulLocStrg = substr_replace($outFulLocStrg, '', -1, 1);
			
			echo 'class="'.$outFulLocStrg.'">';
		}
	}
	
	echo $prglist."</option>\n";


 
	

	if($_POST['programofinterest']=="[URL unfurl="true"]WWWMEDAS"){[/URL] 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('[URL unfurl="true"]wwwlline');}";[/URL]
	echo "</script>";
	}elseif($_POST['programofinterest']=="[URL unfurl="true"]WWWCRIMJUS"){[/URL] 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('[URL unfurl="true"]wwwlline');}";[/URL]
	echo "</script>";
	}elseif($program_row['cvcode']==$_POST['programofinterest']){ 
	echo '<script type="text/javascript">';
	echo "function onloadCampus(){getCurrentOption(document.getElementById('select-program'));enableOptions('display-select-campus');disableFieldsPost('".$outFulLocStrg."');}";
	echo "</script>";
	}
}
?>        
       </select></label>

<p class="required">Not all programs are available at all campuses.</p>   
   

<select name="allcampuses" id="select-campus">
<option value="" selected>---Select A Campus---</option>

<?php
$location_result = mysql_query("SELECT * FROM les_locations ORDER BY state,city") or die(mysql_error());

while($location_row = mysql_fetch_array($location_result)) { 

	$loclist = $location_row['city'].", ".$location_row['state'];
	//$locclass = strtolower(str_replace(",","",str_replace(" ", "", $loclist)));
	$locclass = strtolower(str_replace(" ","",$location_row['state'].$location_row['city']));
	$locURL = strtolower(str_replace(",","",str_replace(" ", "-", $loclist)));
	echo '<option value="'.$location_row['lcode'].'" id="'.$locclass.'" ';	
	if($location_row['lcode']==$_POST['campus']){print "selected class=\"selected\" ";}

	$cvquery = mysql_query("SELECT * FROM les_programs_locations");
	
	$outCvStrg = "";
	while($cvlist = mysql_fetch_array($cvquery)){
		$lid_set = $cvlist['lid'];
		$lidlist = explode("|", $lid_set);

			if(in_array($location_row['lid'], $lidlist)){
				$outCvStrg .= strtolower($cvlist['cvcode']).",";
			}
		
	}
	
	$outCvStrg = substr_replace($outCvStrg, '', -1, 1);
	//echo 'onclick="enableOptions(\'select-program\');disableFields(\''.$outCvStrg.'\')">';
	echo ">".$location_row['state']." - ".$location_row['city']."</option>\n";
}
?>
  </select>
  
<label id="campus-fields" <?php if($program_row['cvcode']==$_POST['programofinterest']){print 'style="display: none" ';} ?><?php error_bool($error, "campus");?> > Campus<span class="required">*</span>
        
  <select name="campus" id="display-select-campus">
  	<option value="" selected>---Select A Campus---</option>
  </select>
  
</label>

<?php if($_POST['programofinterest']){ ?>
<script type="text/javascript">
onloadCampus();
</script> 
<?php } ?> 

</fieldset>


<h2>Please select ONE of the following<span class="required">*</span></h2>

<fieldset class="type-c">
<label <?php error_selectone($error, "todo"); ?> >I would like to Apply for Enrollment  <input name="todo" type="radio" value="AFE" <?php if($_POST['todo']=="AFE"){print "checked";}?>/></label>

<label <?php error_selectone($error, "todo");?> >I would like to Schedule a Campus Tour  <input name="todo" type="radio" value="CT" <?php if($_POST['todo']=="CT"){print "checked";}elseif(!empty($tour)){print "checked";}?>/></label>

<label <?php error_selectone($error, "todo");?> >I would like someone to Contact Me  <input name="todo" type="radio" value="CM" <?php if($_POST['todo']=="CM"){print "checked";}?>/></label>

<label <?php error_selectone($error, "todo");?> >I would like to know about Financial Assistance <input name="todo" type="radio" value="FA" <?php if($_POST['todo']=="FA"){print "checked";}?>/></label>

<label <?php error_selectone($error, "todo");?> >I would like to Receive More Information <input name="todo" type="radio" value="RMI" <?php if($_POST['todo']=="RMI"){print "checked";}elseif(empty($tour)){print "checked";}?>/></label>
</fieldset>

<fieldset class="type-d">

<span>Have You Graduated High School? <span class="required">*</span> </span>
       <label <?php error_selectone($error, "hsdiploma"); ?>>Yes <input onFocus="showElemById('grad-year');hideElemById('still-in-school');hideElemById('have-ged');"
 class="diploma" name="hsdiploma" type="radio" value="Y" <?php if($_POST['hsdiploma']=="Y"){print "checked"; $gradyear="show";}?>/></label> 
       <label <?php error_selectone($error, "hsdiploma"); ?>>No <input onFocus="showElemById('have-ged');hideElemById('grad-year');hideElemById('still-in-school');" name="hsdiploma" class="diploma" type="radio" value="N" <?php if($_POST['hsdiploma']=="N"){print "checked"; $gedfield="show";}?>/></label> 
       <label <?php error_selectone($error, "hsdiploma"); ?>>  Currently in High School<input onFocus="showElemById('still-in-school');hideElemById('grad-year');hideElemById('have-ged');" class="diploma" name="hsdiploma" type="radio" value="C" <?php if($_POST['hsdiploma']=="C"){print "checked"; $stillattend="show";}?>/>  </label> 

</fieldset>
   
<fieldset id="grad-year" class="type-b" style="display: <?=$gradyear?>;">
<label <?php error_bool($error, "yearofhs");?> > Year Graduated: &nbsp;&nbsp;  <select name="yearofhs"><option value="">---Select A Year---</option>        
        		<?
					//$year = date('Y');
					$start = date('Y');
					for($i = 0; $i < 41; $i++) {
						$hs_year = $start - $i;
						echo "<option value=\"";
						echo $hs_year."\"";
							if($_POST['yearofhs']==$hs_year){print "selected";};
						echo ">".$hs_year;
						echo "</option>";
					}
				?>
            </select></label>
</fieldset>

<fieldset id="have-ged" class="type-d" style="display: <?=$gedfield?>;">
<span>Do You Have a GED? <span class="required">*</span> </span>
       <label <?php error_selectone($error, "ged"); ?>>Yes <input class="diploma" name="ged" type="radio" value="Y" <?php if($_POST['ged']=="Y"){print "checked"; $gedfield="show";}?>/></label> 
       <label <?php error_selectone($error, "ged"); ?>>No <input name="ged" class="diploma" type="radio" value="N" <?php if($_POST['ged']=="N"){print "checked"; $gedfield="show";}?>/></label>
</fieldset>

<fieldset id="still-in-school" class="type-b" style="display: <?=$stillattend?>;">
<label <?php error_bool($error, "yearofgrad");?> > Year of Graduation: &nbsp;&nbsp;  <select name="yearofgrad">  <option value="">---Select A Year---</option>      
        		<?
					$year = date('Y');
					//print $year;
					for($i = 0; $i < 4; $i++) {
						$hs_year = $year + $i;
						echo "<option value=\"";
						echo $hs_year."\"";
							if($_POST['yearofgrad']==$hs_year){print "selected";};
						echo "\">";
						echo $hs_year;
						echo "</option>";
					}
				?>
            </select></label>
</fieldset>



<fieldset class="type-b">
<label <?php error_bool($error, "leadsource");?> >Heard About Website From?<span class="required">*</span>
      <select name="leadsource">
      			<option value="">---Select One ---</option>
                <option value="TVW" <?php if($_POST['leadsource']=="TVW"){print "selected";};?>>TV</option>
                <option value="RADW" <?php if($_POST['leadsource']=="RADW"){print "selected";};?>>Radio</option>
                <option value="NPW" <?php if($_POST['leadsource']=="NPW"){print "selected";};?>>Newspaper</option>
                <option value="DMW" <?php if($_POST['leadsource']=="DMW"){print "selected";};?>>Direct Mail</option>
                <option value="BILLW" <?php if($_POST['leadsource']=="BILLW"){print "selected";};?>>Billboard</option>
                <option value="YPW" <?php if($_POST['leadsource']=="YPW"){print "selected";};?>>Yellow Pages</option>
                <option value="REFW" <?php if($_POST['leadsource']=="REFW"){print "selected";};?>>Friend or Relative</option>
                <option value="SEW" <?php if($_POST['leadsource']=="SEW"){print "selected";};?>>Search Engine</option>
                <option value="HSPW" <?php if($_POST['leadsource']=="HSPW"){print "selected";};?>>High School Presentation</option>
  </select></label>
</fieldset>
<input type="hidden" name="Submit" value="submit" onsubmit="return validateForm();"/>
<input type="image" src="/images/buttons/submit-form1.gif" name="imageSubmit" id="submit-form" onClick="showElemById('warning-text');"/>
</form>
<p class="required" id="warning-text" style="display: none;">
Please be patient while your information is submitted to the appropriate campus.
</p>
<?
}
if(isset($_POST["Submit"])) {
    check_form();
} else {
    show_form();
}

function check_email_address($email) {
  // First, we check that there's one @ symbol, and that the lengths are right
  if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
    // Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
    return false;
  }
  // Split it into sections to make life easier
  $email_array = explode("@", $email);
  $local_array = explode(".", $email_array[0]);
  for ($i = 0; $i < sizeof($local_array); $i++) {
     if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
      return false;
    }
  }
  if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { 
  // Check if domain is IP. If not, it should be valid domain name
    $domain_array = explode(".", $email_array[1]);
    if (sizeof($domain_array) < 2) {
        return false; 
		// Not enough parts to domain
    }
    for ($i = 0; $i < sizeof($domain_array); $i++) {
      if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
        return false;
      }
    }
  }
  return true;
}


function check_form()
{
global $HTTP_POST_VARS, $error, $print_again;
$server = getenv('SERVER_NAME');
require "./sites/[URL unfurl="true"]www.test.com/funcs.inc";[/URL]
require "./sites/[URL unfurl="true"]www.test.com/mysql.inc";[/URL]

   
 
	
	
     if(empty($_POST['zip'])) {
        $error['zip'] = true;
         $print_again = true;
        $message.="Please enter a zip code <br>";
    	}
       elseif(!eregi("^([0-9]{5})$", $_POST['zip'])) {
        $error['zip'] = true;
         $print_again = true;
        $message.="Please enter a valid zipcode <br>";
        }
if(empty($_POST['email'])) {
		$error['email'] = true;
		 $print_again = true;
		$message.="Please enter an email address <br>";
	}
	elseif(!check_email_address($_POST['email'])) {
		$error['email'] = true;
		 $print_again = true;
		$message.="Please enter a valid e-mail address <br>";
	}

if($_POST['email']!=$_POST['confirmemail']){
       $error['confirmemail'] = true;
         $print_again = true;
	$message.="Emails dont match.Please check and enter again <br>";
	
	}
    

	if(($_POST['dayphone']=="")) {
        $error['dayphone'] = true;
         $print_again = true;
        $message.="Please enter a daytime phone number <br>";
    	}
	elseif($_POST['dayphone']!="") {
		$_POST['dayphone'] = str_replace("(", "", $_POST['dayphone']);
		$_POST['dayphone'] = str_replace(")", "", $_POST['dayphone']);
			if(!eregi("^([0-9]{3})(-{1}[0-9]{3})(-{1}[0-9]{4})$", $_POST['dayphone'])) {
				$error['dayphone'] = true;
		 		$print_again = true;
				$message.="Please enter a valid daytime phone number <br> (i.e. 212-555-1212) <br />";
				}
		}
	if(empty($_POST['workphone'])) {}
	elseif(!eregi("^([0-9]{3})(-{1}[0-9]{3})(-{1}[0-9]{4})?$", $_POST['workphone'])) {
			$error['workphone'] = true;
			 $print_again = true;
			$message.="Please enter a valid work phone number <br> (i.e. 212-555-1212) <br />";
	}
	if(empty($_POST['cellphone'])) {}
	elseif(!eregi("^([0-9]{3})(-{1}[0-9]{3})(-{1}[0-9]{4})?$", $_POST['cellphone'])) {
			$error['cellphone'] = true;
			 $print_again = true;
			$message.="Please enter a valid cell phone number <br> (i.e. 212-555-1212) <br />";
	}
		
        
	
       
     if($print_again) {
         show_form($message);
       
       } else {

$currenttime = date('H:m:s');
$currentdate = date('Y-m-d');

switch($_POST['hsdiploma']) {
	case 'Y':
	$year = $_POST['yearofhs'];
	break;
	case 'N':
	$year = NULL;
	break;
	case 'C':
	$year = $_POST['yearofgrad'];
	break;
return $year;
}

$server = getenv('SERVER_ADDR');


$vleadID = vendorleadID();
//echo "<br>";
//print_r($_POST);
//echo "</r>";
$strrec = create_students_rec($_POST);

$result = sendLead($strrec, $url, $user, $passwd);

if ($result == "Lead submitted Sucessfully")
{
   update_lead_successful($table_name);

}
						$sendSuccess = true;
						
						show_page($message, $sendSuccess);
						
       }
}

?>

[/code]
 
First, this is a Javascript forum, not a PHP forum. If you want to show HTML, you gotta show the HTML output.

Second, I accidentally had a typo in this line:
Code:
for(i = ele.length - 1; i >- 0; i++)

Since you're a PHP programmer, you should be able to find it.

Lee
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top