FORUMS


The Form Tools forums are no longer active, but the old posts have been archived here. Please see the Help page on how to get help / report issues.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Later than a set date
#1
Question 
Hello

i would like to use the later_date, but checking that the imput date is later than a set date, different than today's date.
eg i would like to verify that inclusion date is later than nov 1st 2009

is there any way to do this ?

thanks

alexis
Reply
#2
Hi Alexis,

Sure! Is this for the client-side (RSV) validation script or the PHP version?

The built-in date functionality within the RSV script isn't very strong, so what you'd need to do is write a custom function that examines the form field value(s). Let me know which script you're interested in and I'll give you a few further pointers.

- Ben
Reply
#3
I am using RSV, but can switch to php if required.

here's what i am trying to do: we use FT to include patients in a medical survey.

rules of inclusion include
- the patient can't be included before the study start date in the hospital (get the date from a database and transform to variable. date of inclusion is not date of today but 3 forms fields in the actual form.
- the patient can only be included if the date of event (3 form fields day,month,year) is 2 days later than the date of admissions (3 form fields day,month,year). both in the actual form that i want to verify

if i can do this, there are other more complicated date validations that i should be able to do

thank you

Alexis
Reply
#4
Hey Alexis,

Thanks for the reminder about this post.

So! Here's some very general pointers on how to do this for the JS RSV script. Since the built-in date validation code is pretty basic, we're going to bypass it altogether and write a custom function to do the validation for us. First, add a new rule to your rule list: this will call your custom function.

Code:
rules.push("function,check_date");

Next, as you described in your post, the check_date() function needs to do a couple of things. I wasn't completely sure about the rules you need to check for, but here's an example of how it would look:

Code:
function check_date() {
  // this bit would be generated server-side. This example assumes you're using PHP and the
  // date is in yyyy-mm-dd format.
  var study_date_start = "<?=$study_date_start?>";

  // 1. find the form fields that contain the dates.

  // 2. do whatever tests you want. You'd no doubt compare it with the value in study_date_start

  // 3. if there are errors, return a variable like this - where problem_field is a reference to
  // the form field that has a problem (e.g. document.getElementById("field1") )
  // return [[problem_field, "your error message"]];

  // if there are no error messages, return true:
  return true;
}

That's the gist of it... the validation logic will be the next bit to sort out. Basically you'd need to extract & compare the various dates and do the math on them.

Sorry I'm being so general, but hopefully this gives you some idea of how to proceed - at least how to plug it into the main validation control flow.

- Ben
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)