close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Validating End Date > Start Date

Thread began 7/13/2010 9:42 am by dinohorn397192 | Last modified 7/14/2010 2:58 pm by Jimmy Wu | 1657 views | 3 replies |

dinohorn397192

Validating End Date > Start Date

I have two fields in my form that I want to compare, I want to make sure the enddate field as greater than the start date field...

<input type="text" id="startdate" name="startdate" class="inputForm" disabled="disabled" />

<input type="text" id="enddate" name="enddate" class="inputForm" disabled="disabled" />

Is there a way it can be done with "Min Date" option in the Server Validations wizard?

Thanks,

Sign in to reply to this post

Jimmy Wu

This requires a bit of modification on your part. You will have to change the min date to be changed dynamically based on the first form field. What I would recommend doing is to set some placeholder text into the min date field, so you can tell where in the code you need to make the change. In this example I used "aaaaaaaaaaaaaaa". I have applied date validation on the 2 fields, on the second one I have added the placeholder min date text. The validation code added looks similar to this:

php:
<?php 

if ($_SERVER["REQUEST_METHOD"] == "POST")  {
  
$WAFV_Redirect "";
  
$_SESSION['WAVT_untitled2_264_Errors'] = "";
  if (
$WAFV_Redirect == "")  {
    
$WAFV_Redirect $_SERVER["PHP_SELF"];
  }
  
$WAFV_Errors "";
  
$WAFV_Errors .= WAValidateDT(((isset($_POST["textfield"]))?$_POST["textfield"]:"") . "",true,".*","","",false,".*","","",true,1);
  
$WAFV_Errors .= WAValidateDT(((isset($_POST["textfield2"]))?$_POST["textfield2"]:"") . "",true,".*","aaaaaaaaaaaaaaa","",false,".*","","",true,2);

  if (
$WAFV_Errors != "")  {
    
PostResult($WAFV_Redirect,$WAFV_Errors,"untitled2_264");
  }
}
?>



You would want to make modifications so the code looks like this:

php:
<?php 

if ($_SERVER["REQUEST_METHOD"] == "POST")  {
  
$WAFV_Redirect "test.php";
  
$_SESSION['WAVT_untitled2_264_Errors'] = "";
  if (
$WAFV_Redirect == "")  {
    
$WAFV_Redirect $_SERVER["PHP_SELF"];
  }
  
$WAFV_Errors "";
  
$WAFV_Errors .= WAValidateDT(((isset($_POST["textfield"]))?$_POST["textfield"]:"") . "",true,".*","","",false,".*","","",true,1);
  
$WAFV_Errors .= WAValidateDT(((isset($_POST["textfield2"]))?$_POST["textfield2"]:"") . "",true,".*",((isset($_POST["textfield"]))?$_POST["textfield"]:""),"",false,".*","","",true,2);

  if (
$WAFV_Errors != "")  {
    
PostResult($WAFV_Redirect,$WAFV_Errors,"untitled2_264");
  }
}
?>



Basically what I have done is to check the value that was posted in the first checkbox and checked it against the one input in the second checkbox. To do this, I have replaced the "aaaaaaaaaaaaaaa" with ((isset($_POST["textfield"]))?$_POST["textfield"]:"")

Sign in to reply to this post

dinohorn397192

Tricky! It's working now, thanks!

Sign in to reply to this post

Jimmy Wu

Great to hear it. If you run into any additional issues, feel free to open a new thread.

Sign in to reply to this post

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...