Solved

Need JavaScrpt Code Sample to Validate Form Date Field

Posted on 2008-10-03
7
416 Views
Last Modified: 2010-04-21
Greetings,

I have a web form that is emailed to us once it is filled out. It also has a date field, that needs to be validated somehow to not allow input of any days within 3 days from now. So the min. date field acceptable should be 10/06/08 (3 days from now). I was pointed to a great link below, but unfortunately I have no experience with AJAX or JavaScript for that matter. So I have no idea how to implement this. I downloaded the AJAX library with all the .js files, and uploaded them to my server. The only problem is to implement it. The web form code is posted below. If anyone can provide a code sample to implement this that would be great.

Any other ways (code samples) to validate my date field are also welcome.

http://www.frequency-decoder.com/2006/10/02/unobtrusive-date-picker-widgit-update/
<!DOCTYPE html public "-//W3C//DTD HTML 4.01 Transitional//EN">

<HTML>

<HEAD>

<TITLE>Contact domain Court Reporters</TITLE>

<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
 

<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>

<SCRIPT language="JavaScript" type="text/JavaScript">

<!--

function MM_preloadImages() { //v3.0
 

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
 

    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
 

    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
 

}

//-->

</SCRIPT>

<STYLE type="text/css">

<!--
 

.style4 {font-family: Arial, Helvetica, sans-serif}
 

a:link {
 

        color: #FFFFFF;
 

}
 

a:visited {
 

        color: #FFFFFF;
 

}

.style7 {color: #000000}

.style9 {

	color: #FFFFFF;

	font-family: Arial, Helvetica, sans-serif;

	font-size: 16px;

}

.style13 {font-size: 26px}

.style14 {

	color: #999999;

	font-size: 14;

	font-style: italic;

}

.style15 {font-size: 10px}
 

-->

</STYLE>
 

<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">

<style type="text/css">

<!--

.style17 {color: #CC3333}

-->

</style>

</HEAD>
 

<BODY bgcolor="3e5368" text="#FFFFFF">

        <table width="756" border="0">

  <tr>

    <td width="292"><img src="../images/logo.gif" width="149" height="56"></td>

    <td width="454"></td>

  </tr>

</table>
 
 

        <table width="955" height="844" border="0" cellpadding="10">

          <tr>

            <td width="183" valign="top"><p><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif"><a href="../">www.domain.com</a></font></p>

                <table width="170" border="1" bordercolor="#DBD9CD" bgcolor="#DBD9CD">

                  <tr>

                    <td width="130" bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="client_home.html">Home</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="services.html">Services</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="support.html">Support</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="training.html">Training</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="contact.html">Contact</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="../repository">On-Site Repository</a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="http://www.domaintt.com">Trial Technology </a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="https://web.domain.com/attorney/">domainWeb<font face="Symbol">&#0153;</font> </a></span> </td>

                  </tr>

                  <tr>

                    <td bordercolor="#878884" bgcolor="#8AABC9"><span class="style4"><a href="http://www.webdocument.net/domainreporting">domainE-Repository<font face="Symbol">&#0153;</font> </a></span></td>

                  </tr>

                </table>

              <p>&nbsp;</p></td>

            <td height="324" align="center">

            

            <p class="style9"><span class="style13">Schedule a Deposition</span></p>

            <p class="style9"><a href="../web/attorney.htm">Already have a <strong>domainWeb&#8482;</strong> account?</a></p>

            <p class="style9">OR</p>

            <p class="style9">Fill out the form below:</p>

            <table width="813" height="1094" border="0" align="center" background="../Images/sheduledepo1100.gif">

              <tr>

                <td width="807" height="1090" align="left" valign="top"><table width="804" height="1031" border="0">

                  <tr>

                    <td height="974" colspan="2" valign="top">

                    

                    <form action="scheduleform-process.php" method="post">

                      <p align="center">&nbsp;</p>

                      <table width="764" height="926" border="0" align="center" cellpadding="1">

                        <tr>

                          <td width="249"><span class="style9">Request Type:</span></td>

                          <td width="497"><span class="style9">

                      <select name="RqstType" size="1" class="style7" id="RqstType">

                              <option selected>New</option>

                              <option>Change</option>

                              <option>Cancellation</option>

                              <option>Confirmation</option>

                          </select>

                          </span></td>

                        </tr>

                        <tr>

                          <td class="style9">Deposition Date:</td>

                          <td><span id="sprytextfield1">

                          <input name="JobDate" type="text" class="style7" id="JobDate" size="40">

                          <span class="textfieldRequiredMsg"></span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span> (mm/dd/yyyy) </td>

                        </tr>

                        <tr>

                          <td class="style9">&nbsp;</td>

                          <td><span class="style17">Deposition date must be at least 3 days from today.</span></td>

                        </tr>

                        <tr>

                          <td class="style9">Time Zone:</td>

                          <td><span class="style9">

                            <select name="TimeZone" size="1" class="style7" id="TimeZone">

                              <option selected>Pacific Time (PST)</option>

                              <option>Mountain Time (MST)</option>

                              <option>Central Time (CST)</option>

                              <option>Eastern Time (EST)</option>

                            </select>

                          </span></td>

                        </tr>

                        <tr>

                          <td class="style9">Deposition Time:</td>

                          <td><span class="style9">

Start Time:

    <span id="sprytextfield7">

    <input name="StartTime" type="text" class="style7" id="StartTime" size="21">

    <span class="textfieldRequiredMsg"></span></span>

End Time:

<input name="EndTime" type="text" class="style7" id="EndTime" size="21">

                          </span></td>

                        </tr>

                        <tr>

                          <td class="style9">Ordered By:</td>

                          <td valign="middle" class="style9">First Name:

                            <span id="sprytextfield5">

                            <input name="OrderedByFirstName" type="text" class="style7" id="OrderedByFirstName">

                            <span class="textfieldRequiredMsg"></span>                            </span> 

                            Last Name: 

                            <span id="sprytextfield6">

                            <input name="OrderedByLastName" type="text" class="style7" id="OrderedByLastName">

                            <span class="textfieldRequiredMsg"></span></span></td>

                        </tr>

                        <tr>

                          <td class="style9">Attorney:</td>

                          <td valign="middle" class="style9">First Name:

                            <input name="ContactFirstName" type="text" class="style7" id="ContactFirstName"> 

                          Last Name: 

                          <input name="ContactLastName" type="text" class="style7" id="ContactLastName">                          </td>

                        </tr>

                        <tr>

                          <td class="style9">Phone: </td>

                          <td valign="middle"><input name="ContactPhone" type="text" class="style7" id="ContactPhone" size="66"></td>

                        </tr>

                        <tr>

                          <td class="style9">Mobile: <span class="style15">(Required for after-hour depositions)</span></td>

                          <td valign="middle"><input name="ContactMobile" type="text" class="style7" id="ContactMobile" size="66"></td>

                        </tr>

                        <tr>

                          <td class="style9">Fax Number: <span class="style15">(to send confirmation)</span></td>

                          <td valign="middle"><span id="sprytextfield8">

                          <input name="ContactFax" type="text" class="style7" id="ContactFax" size="66">

                          <span class="textfieldRequiredMsg"></span></span></td>

                        </tr>

                        <tr>

                          <td class="style9">E-mail: <span class="style15">(to send confirmation)</span></td>

                          <td valign="middle"><span id="sprytextfield2">

                          <input name="ContactEmail" type="text" class="style7" id="ContactEmail" size="50">

                          <span class="textfieldRequiredMsg"></span><span class="textfieldInvalidFormatMsg">Invalid format.</span></span></td>

                        </tr>

                        <tr>

                          <td class="style9">Firm Name:</td>

                          <td valign="middle"><span id="sprytextfield9">

                            <input name="FirmName" type="text" class="style7" id="FirmName" size="66">

                          <span class="textfieldRequiredMsg"></span></span></td>

                        </tr>

                        <tr>

                          <td><span class="style9">Deposition Location:</span></td>

                          <td><table width="426" border="0">

                            <tr>

                              <td width="161"><span class="style9">Location Name: </span></td>

                              <td width="255"><span id="sprytextfield10">

                                <input name="LocName" type="text" class="style7" id="LocName" size="40">

                              <span class="textfieldRequiredMsg"></span></span></td>

                            </tr>

                            <tr>

                              <td><span class="style9">Address:</span></td>

                              <td><span class="style9">

                                <input name="LocAddress" type="text" class="style7" id="LocAddress" size="40">

                              </span></td>

                            </tr>

                            <tr>

                              <td><span class="style9">City:</span></td>

                              <td><span class="style9">

                                <input name="LocCity" type="text" class="style7" id="LocCity" size="40">

                              </span></td>

                            </tr>

                            <tr>

                              <td><span class="style9">State: </span></td>

                              <td><span class="style9">

                                <input name="LocState" type="text" class="style7" id="LocState" size="40">

                              </span></td>

                            </tr>

                            <tr>

                              <td class="style9">Zip:</td>

                              <td><input name="LocPostCode" type="text" class="style7" id="LocPostCode" size="40"></td>

                            </tr>

                            <tr>

                              <td class="style9">Phone:</td>

                              <td><input name="LocPhone" type="text" class="style7" id="LocPhone" size="40"></td>

                            </tr>

                          </table></td>

                        </tr>

                        <tr>

                          <td><span class="style9">Deponent 1:</span></td>

                          <td><span id="sprytextfield11">

                            <input name="Witness1" type="text" class="style7" id="Witness1" size="66">

                          <span class="textfieldRequiredMsg"></span></span></td>

                        </tr>

                        <tr>

                          <td><span class="style9">Deponent 2:</span></td>

                          <td><input name="Witness2" type="text" class="style7" id="Witness2" size="66"></td>

                        </tr>

                        <tr>

                          <td><span class="style9">Deponent 3:</span></td>

                          <td><input name="Witness3" type="text" class="style7" id="Witness3" size="66"></td>

                        </tr>

                        <tr>

                          <td class="style9">Expert Type:</td>

                          <td><span class="style9">

                            <select name="ExpertType" size="1" class="style7" id="ExpertType">

                              <option selected>Not an expert witness</option>

                              <option>Accident &amp; Injury</option>

                              <option>Business &amp; Financial</option>

                              <option>Civil Litigation</option>

                              <option>Construction &amp; Architecture</option>

                              <option>Criminal Litigation</option>

                              <option>Medical &amp; Psychological</option>

                              <option>Patent Infringement</option>

                              <option>Science &amp; Engineering</option>

                            </select>

                          </span></td>

                        </tr>

                        <tr>

                          <td><span class="style9">Case Name:</span></td>

                          <td><span id="sprytextfield12">

                            <input name="CaseName" type="text" class="style7" id="CaseName" size="66">

                          <span class="textfieldRequiredMsg"></span></span></td>

                        </tr>

                        <tr>

                          <td align="left"><span class="style9">Case #:</span></td>

                          <td><input name="CauseNo" type="text" class="style7" id="CauseNo" size="66"></td>

                        </tr>

                        <tr>

                          <td class="style9">Additional Services:</td>

                          <td><table width="426" border="0">

                            <tr>

                              <td class="style9"><input name="Video" type="checkbox" class="style9" id="Video" value="Video Checked"> 

                                Video 

                                <input name="Interpreter" type="checkbox" id="Interpreter" value="Interpreter Checked">

                                Interpreter<span class="style14">, 

                                <span id="sprytextfield4">

                                <input name="Language" type="text" class="style14" id="Language" size="25">

                              </span>                              </span></td>

                            </tr>

                            <tr>

                              <td class="style9"> <input name="GreenCopy" type="checkbox" id="GreenCopy" value="GreenCopy Checked">

                              GreenCopy&#8482; PDF* ($40 Discount)</td>

                            </tr>

                            <tr>

                              <td class="style9"><input name="RealTime" type="checkbox" class="style9" id="RealTime" value="Real-Time Checked"> 

                                Interactive Real-time</td>

                            </tr>

                            <tr>

                              <td class="style9"><input name="Expedite" type="checkbox" class="style9" id="Expedite" value="Expedite Checked">

                              Expedite/Trial Date<span id="sprytextfield3">

                              <input name="TrialDate" type="text" class="style14" id="TrialDate" size="26">

                              </span></td>

                            </tr>

                          </table></td>

                        </tr>

                        <tr>

                          <td class="style9">Sign up for <strong>domainWeb&#8482;</strong>?</td>

                          <td valign="top"><label>

                            <input type="radio" name="domainWeb" value="Yes" id="domainWeb_0">

Yes</label>

                            <input type="radio" name="domainWeb" value="No" id="domainWeb_1">

                            <label>No</label></td>

                        </tr>

                        <tr>

                          <td height="77"><input name="ScheduledDate" type="hidden" id="ScheduledDate" value="<?php echo date("Y-m-j H:i:s");?>"></td>

                          <td><input name="submit" type="submit" class="style7" id="submit" value="Submit">

                          <input name="reset" type="reset" class="style7" id="reset" value="Reset"></td>

                        </tr>

                      </table>

                    </form>                    </td>

                  </tr>

                  <tr>

                    <td width="765" height="51" valign="top"><div align="center"><img src="../Images/sheduledepotree.gif" width="343" height="36" border="0" usemap="#Map"></div></td>

                    <td width="29" valign="top">&nbsp;</td>

                  </tr>

                </table>                

                </td>

              </tr>

              </table>

            </td>

          </tr>

            </table>

          <P><FONT color="#FFFFFF" size="1" face="Arial, Helvetica, sans-serif">&copy; 2008 

  domain Court Reporters</FONT></P>

       

<map name="Map"><area shape="rect" coords="2,3,364,45" href="../PDF Files/domainEarthSmallPC08.pdf" target="_blank">

</map><script type="text/javascript">

<!--

var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "date", {format:"mm/dd/yyyy"});

var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");

var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {isRequired:false, hint:"Trial Date"});

var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "none", {isRequired:false, hint:"Language"});

var sprytextfield5 = new Spry.Widget.ValidationTextField("sprytextfield5", "none");

var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6");

var sprytextfield7 = new Spry.Widget.ValidationTextField("sprytextfield7");

var sprytextfield8 = new Spry.Widget.ValidationTextField("sprytextfield8", "none");

var sprytextfield9 = new Spry.Widget.ValidationTextField("sprytextfield9");

var sprytextfield10 = new Spry.Widget.ValidationTextField("sprytextfield10");

var sprytextfield11 = new Spry.Widget.ValidationTextField("sprytextfield11");

var sprytextfield12 = new Spry.Widget.ValidationTextField("sprytextfield12");

//-->

</script></BODY>
 

</HTML>

Open in new window

0
Comment
Question by:pzozulka
  • 5
  • 2
7 Comments
 
LVL 6

Accepted Solution

by:
deresh earned 500 total points
ID: 22636688
you should not depend on data validation that is done on client side, you should do validation on the server with php script:

addiming that name of the date input field is "data" and method = POST

<?php

$date = strftime($_POST['date'],time());

if($date < 259200) // 259200 is number of seconds for 3 days
  echo "date entered is not 3 days from now!";

?>
0
 
LVL 8

Author Comment

by:pzozulka
ID: 22639047
Hey deresh, that looks like a good solution as well. I don't mind using server side validation via php at all. Just not too familiar with php. Anyway, I'll give it a try on Monday, and I'll let you know, thanks for your response.
0
 
LVL 8

Author Comment

by:pzozulka
ID: 22651529
I have attached the server side php script that emails the form. I inserted your code all the way at the top, was this the correct place to insert it?

Anyways it sort of worked. It gave me the error message, but it displayed it on the Thank You page, and emailed it out anyway.
<?
 

$JobDate = strftime($_POST['JobDate'],time());
 

if($date < 259200) // 259200 is number of seconds for 3 days

  echo "Date entered is not 3 days from now!";
 

// Post value declarations
 

$RqstType = $_POST["RqstType"];
 

$JobDate = $_POST["JobDate"];
 

$TimeZone = $_POST["TimeZone"];
 

$StartTime = $_POST["StartTime"];
 

$EndTime = $_POST["EndTime"];
 

$ScheduledDate = $_POST["ScheduledDate"];
 

$OrderedByFirstName = $_POST["OrderedByFirstName"];
 

$OrderedByLastName = $_POST["OrderedByLastName"];
 

$ContactFirstName = $_POST["ContactFirstName"];
 

$ContactLastName = $_POST["ContactLastName"];
 

$ContactMobile = $_POST["ContactMobile"];
 

$ContactPhone = $_POST["ContactPhone"];
 

$ContactFax = $_POST["ContactFax"];
 

$ContactEmail = $_POST["ContactEmail"];
 

$FirmName = $_POST["FirmName"];
 

$LocName = $_POST["LocName"];
 

$LocAddress = $_POST["LocAddress"];
 

$LocCity = $_POST["LocCity"];
 

$LocState = $_POST["LocState"];
 

$LocPostCode = $_POST["LocPostCode"];
 

$LocPhone = $_POST["LocPhone"];
 

$Witness1 = $_POST["Witness1"];
 

$Witness2 = $_POST["Witness2"];
 

$Witness3 = $_POST["Witness3"];
 

$ExpertType = $_POST["ExpertType"];
 

$CaseName = $_POST["CaseName"];
 

$CauseNo = $_POST["CauseNo"];
 

$Video = $_POST["Video"];
 

$Interpreter = $_POST["Interpreter"];
 

$GreenCopy = $_POST["GreenCopy"];
 

$Language = $_POST["Language"];
 

$RealTime = $_POST["RealTime"];
 

$Expedite = $_POST["Expedite"];
 

$TrialDate = $_POST["TrialDate"];
 

$domainWeb = $_POST["domainWeb"];
 

// To send HTML mail, the Content-type header must be set
 

$headers  = 'MIME-Version: 1.0' . "\r\n";
 

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
 

// Additional headers
 

$headers .= 'From: support@domain.com <domain Support>' . "\r\n"; // This isn't working (ever) could be host anti-spam thing.
 

// $headers .= 'Cc:' . $EMail . "\r\n"; // Copy to ordering person (removed per request on 7/29/08)
 

$headers .= 'Bcc: pavelz@domain.com' . "\r\n"; // Copy to me as test
 

// Create repository order email
 

$to  = 'rinam@domain.com' . ', '; // note the comma
 

$to  .= 'elenab@domain.com' . ', ';
 

$to  .= 'saquibr@domain.com' . ', ';
 

$to  .= 'nicoleh@domain.com' . ', ';
 

$to  .= 'yavonk@domain.com' . ', ';
 

$to  .= 'jennifers@domain.com';
 

$subject = "Schedule a Deposition";
 

$message= "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
 

<html xmlns=\"http://www.w3.org/1999/xhtml\">
 

<head>
 

<title>Schedule a Deposition</title>
 

<style type=\"text/css\">font.n{ color:#ffffff; font-size:13px; font-family:arial, helvetica; text-decoration:none;}
 

font.a{ color:006699; font-size:15px; font-family:arial, helvetica;}
 

font.ax{ color:ffffff; font-size:12px; font-family:arial, helvetica; text-decoration: none;}
 

font.b{ color:#000000; font-size:14px; font-family:arial, helvetica; text-decoration:none;}
 

font.bx{ color:#000000; font-size:13px; font-family:arial, helvetica; text-decoration:none; background: white}
 

font.c{ color:#9999cc; font-size:21px; font-family:arial, helvetica;}
 

font.d{ color:#000000; font-size:16px; font-family:arial, helvetica;}
 

font.e{ color:#000000; font-size:12px; font-family:arial, helvetica;}
 

font.f{
 

        color: Red;
 

        font-size: 12px;
 

        font-family:arial, helvetica;
 

        text-decoration:none;
 

        font-style : italic;
 

}
 

BODY, DIV, TD, LAYER { font-size:8.5pt; font-family:arial; font-color:white;}
 

A:link { color:blue; text-decoration:none; }
 

A:visited { color:blue; text-decoration:none; }
 

A:hover, { color:red; text-decoration:none; }
 

A:active { color:red; text-decoration:none; }
 

.style2 {font-size: 14}
 

.style4 {font-family: Arial, Helvetica, sans-serif}
 

.style5 {font-family: Arial, Helvetica, sans-serif; font-size: 14;}
 

.style6 {font-size: 10px}
 

.style7 {font-size: 12px}
 

.style8 {font-size: 14px}</style>
 

<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" />
 

</head>
 
 
 

<body>
 
 
 

<table width=\"550\" border=\"0\" cellpadding=\"5\" cellspacing=\"5\" bgcolor=\"#9999CC\">
 

  <tr>
 

    <td colspan=\"2\" scope=\"row\"><b>Depo Scheduled</b></td>
 

  </tr>
 

  <tr>
 

    <td align=\"left\" scope=\"row\" bgcolor=\"#9999CC\" width=\"25%\">Request Type: </td>
 

    <td width=\"75%\" bgcolor=\"#FFFFFF\">$RqstType</td>
 

  </tr>
 

  <tr>
 

    <td align=\"left\" scope=\"row\" bgcolor=\"#9999CC\">Job Date: <br /></td>
 

    <td bgcolor=\"#FFFFFF\">$JobDate</td>
 

  </tr>
 

  <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Time Zone: </td>
 

    <td bgcolor=\"#FFFFFF\">$TimeZone</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Start Time: </td>
 

    <td bgcolor=\"#FFFFFF\">$StartTime</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">End Time: </td>
 

    <td bgcolor=\"#FFFFFF\">$EndTime</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Date & Time Scheduled (Mountain Standard Time): </td>
 

    <td bgcolor=\"#FFFFFF\">$ScheduledDate</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Ordered By First Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$OrderedByFirstName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Ordered By Last Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$OrderedByLastName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Attorney First Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactFirstName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Attorney Last Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactLastName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Phone: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactPhone</td>
 

  </tr>
 

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Mobile: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactMobile</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Fax: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactFax</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Email: </td>
 

    <td bgcolor=\"#FFFFFF\">$ContactEmail</td>
 

  </tr>
 

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Firm Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$FirmName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location Address: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocAddress</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location City: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocCity</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location State: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocState</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location Zip: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocPostCode</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Location Phone: </td>
 

    <td bgcolor=\"#FFFFFF\">$LocPhone</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Deponent1: </td>
 

    <td bgcolor=\"#FFFFFF\">$Witness1</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Deponent2: </td>
 

    <td bgcolor=\"#FFFFFF\">$Witness2</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Deponent3: </td>
 

    <td bgcolor=\"#FFFFFF\">$Witness3</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Expert Type: </td>
 

    <td bgcolor=\"#FFFFFF\">$ExpertType</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Case Name: </td>
 

    <td bgcolor=\"#FFFFFF\">$CaseName</td>
 

  </tr>

  

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Case Number: </td>
 

    <td bgcolor=\"#FFFFFF\">$CauseNo</td>

    

   </tr>

   

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Video: </td>
 

    <td bgcolor=\"#FFFFFF\">$Video</td>

    

      </tr>
 

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Interpreter: </td>
 

    <td bgcolor=\"#FFFFFF\">$Interpreter</td>

    

      </tr>

      

     <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Interpreter Language: </td>
 

    <td bgcolor=\"#FFFFFF\">$Language</td>
 

      </tr>

      

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">GreenCopy: </td>
 

    <td bgcolor=\"#FFFFFF\">$GreenCopy</td>
 

      </tr>

    

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">RealTime: </td>
 

    <td bgcolor=\"#FFFFFF\">$RealTime</td>

    

      </tr>
 

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Expedite: </td>
 

    <td bgcolor=\"#FFFFFF\">$Expedite</td>

    

      </tr>

    

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Trial Date: </td>
 

    <td bgcolor=\"#FFFFFF\">$TrialDate</td>
 

      </tr>

      

    <tr>
 

    <td align=\"left\"  scope=\"row\" bgcolor=\"#9999CC\">Sign up for domainWeb? </td>
 

    <td bgcolor=\"#FFFFFF\">$domainWeb</td>
 

      </tr>
 

</table>
 

</body>
 

</html>";
 

// Mail Repository order using values from above
 

mail($to, $subject, $message, $headers);
 
 
 

// Create confirmation page
 
 
 

echo"<html>
 

<head>
 

<title>Schedule a Deposition</title>
 

<style type=\"text/css\">
 

font.n{ color:#ffffff; font-size:13px; font-family:arial, helvetica; text-decoration:none;}
 

font.a{ color:006699; font-size:15px; font-family:arial, helvetica;}
 

font.ax{ color:ffffff; font-size:12px; font-family:arial, helvetica; text-decoration: none;}
 

font.b{ color:#000000; font-size:14px; font-family:arial, helvetica; text-decoration:none;}
 

font.bx{ color:#000000; font-size:13px; font-family:arial, helvetica; text-decoration:none; background: white}
 

font.c{ color:#9999cc; font-size:21px; font-family:arial, helvetica;}
 

font.d{ color:#000000; font-size:16px; font-family:arial, helvetica;}
 

font.e{ color:#000000; font-size:12px; font-family:arial, helvetica;}
 

font.f{
 

        color: Red;
 

        font-size: 12px;
 

        font-family:arial, helvetica;
 

        text-decoration:none;
 

        font-style : italic;
 

}
 

BODY, DIV, TD, LAYER { font-size:8.5pt; font-family:arial; font-color:white;}
 

A:link { color:blue; text-decoration:none; }
 

A:visited { color:blue; text-decoration:none; }
 

A:hover, { color:red; text-decoration:none; }
 

A:active { color:red; text-decoration:none; }
 

.style1 {
 

        font-size: 12pt;
 

        font-weight: bold;
 

}
 

</style>
 

<meta name=\"robots\" content=\"noindex\">

</head>
 

<body bgcolor=\"#ffffff\" leftmargin=0 topmargin=0 marginwidth=0 marginheight=0>
 

<table cellpadding=2 cellspacing=0 border=0 width=\"780\" bgcolor=\"#ffffff\">
 

<tr>
 

<td rowspan=6 bgcolor=\"#9999cc\" width=48 height=300><font class=c>&nbsp;</font></td>
 

<td rowspan=6 bgcolor=\"#ffffff\" width=10></td>
 

<td colspan=2 valign=middle>
 

<br>
 

<font class=c>Form Submitted</font><br>
 

</td>
 

<td width=\"304\">&nbsp;</td>
 

</tr>
 

<tr>
 

<td colspan=3 valign=top>
 

<hr noshade size=1 color=\"#cccccc\">

<hr noshade size=1 color=\"#cccccc\">

<table width=\"650\" border=\"0\" cellspacing=\"0\" cellpadding=\"15\" bgcolor=\"#EEEEEE\">
 

<tr>
 

  <td height=\"50\">

  <div><font class=\"b\" size=\"1\">Thank you for scheduling a deposition with domain Court Reporters! We will process your form shortly.
 

</font></div>

</td></tr>

</table>

</body>

</html>";

?>

Open in new window

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 8

Author Comment

by:pzozulka
ID: 22651599
Oh and sorry up there is a typo, your code was modified to look like this:

$JobDate = strftime($_POST['JobDate'],time());
 
if($JobDate < 259200) // 259200 is number of seconds for 3 days
  echo "Date entered is not 3 days from now!";
0
 
LVL 6

Expert Comment

by:deresh
ID: 22653268
that was only a example in your script you need to redirect back to form, see code below.

the code stores error in user session so that it can be displayed ona the form page somewhere.

and now it won't send you data until the date is correctly entered.
<?

 

$JobDate = strftime($_POST['JobDate'],time());

 

if($date < 259200) // 259200 is number of seconds for 3 days

{

  $_SESSION['error'] = "Date entered is not 3 days from now!";

  header('Location: http://url_to_page/with_form');

  exit;

}

?>
 

and on the form page somewhere appropriate:
 

<? if(isset($_SESSION['error']): ?>

<span style="color: red;"><?php echo $_SESSION['error']; ?>

<? endif; ?>

Open in new window

0
 
LVL 8

Author Comment

by:pzozulka
ID: 22654129
I cannot access the form anymore. It gives me an error message right away:
Parse error: syntax error, unexpected ':' in /home1/barkleyc/public_html/client/test1.php on line 70
Here is line 70:
<? if(isset($_SESSION['error']): ?>

I tried renaming my form page to .html instead of .php, and that eliminates the error. However when I submit my form, nothing happens, I just get redirected back to the form page, regardless of JobDate. What's causing this behavior?
0
 
LVL 8

Author Closing Comment

by:pzozulka
ID: 31502816
Here is the code that worked for me:
<?

$myFieldDate = strtotime($_POST['myFieldDate']);
$newdate = strtotime("+3 day");
if($myFieldDate < $newdate)
{ session_start();
  $_SESSION['error'] = "Please choose different Date!";
  header('Location: http://domain.com/client/test1.php');
  exit;
}?>

On the Form Page itself, all the way at the top:
<? session_start();
?>
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now