Restrict Date/Time Field

Hi,

I have two date/time fields in a form. In both the existing event I have written code which checks for weekend date and displays msgbox. Let me name them date1 and date2. So if I’m in date1 and select weekend as my date. If I click on the date2 field I get msgbox but calendar opens for date2. How to restrict the calendar to pop-up since then the purpose of writing code in existing event does not satisfy.

Hope you have understood what I am trying to say. On the date/time field there’s calendar icon and on clicking that this happens.

Please any ideas or help would be great.

Subject: Restrict Date/Time Field

What if you hide your second DataTime field and show a CFD non-editable version whenever the first field doesn’t pass validation?

Subject: RE: Restrict Date/Time Field

Yah but that is too much of work since I may click date2 field directly then I will have to write code to make date1 non-editable and vice versa.

Subject: RE: Restrict Date/Time Field

Seems easy to me.

First, I’d add two CFD number fields to hold the validation as flags…

$$HideDate1Flag

$$HideDate2Flag

Their formulas are:

@If(

@Weekday(Date2)=1; @True;

@Weekday(Date2)=7; @True;

@False)

@If(

@Weekday(Date1)=1; @True;

@Weekday(Date1)=7; @True;

@False)

You have four date fields and their Hide-Formulas in parens …

Date1 (!$$HideDate1Flag)

$$Date1NoEdit ($$HideDate1Flag)

Date2 (!$$HideDate2Flag)

$$Date2NoEdit ($$HideDate2Flag)

Make sense?

Subject: RE: Restrict Date/Time Field

I tried it but got error for the $$Hidedate1flag. Is there any other way without having too many fields, since I mentioned only 2 dates in my previous mail, in reality I have 5 date/time fields and imagine having too many flag fields and then double the date/time field.

Subject: RE: Restrict Date/Time Field

Not to my knowledge.

Also realize that the flag fields REDUCE the number of calculations on the page. You have 2 hide/whens using the flag, but only need to do the evaluation once. This is good. Also these are Computed For Display fields, so they are really just containers for your logic, not data in your document, per se.

What error did you get?

I do this kind of relationship all the time. Its nice, because all the (normally buried) hide logic is right together at the top of the page in hidden fields. Also its easy to understand:

Whenever your HideFlag is ‘True’ then it’s hidden.

Subject: RE: Restrict Date/Time Field

Thanks Brian. Instead of using hidden fields I wrote a formula in Input Validation which doesn’t allow user to go to another field if not correct. And if this doesnt work I have written in save event too, there by documents don’t get saved if date is weekend.