July 30, 200619 yr when a user enters a date of birth into my date of birth field i have a calculation field called age which displays their age which is set up to be green if 18 or older, orange if 17 or red if under 17. is it possible to set it up so if the age is 17 aswell as colour change a message is displayed to the user and if under 17 it is not allowed.
July 31, 200619 yr You can attach field-level validation to the DOB field using the calc field for direction. So your age calc might look something like this: Let ( [ now = Get ( CurrentDate ) ; thisBD = Date ( Month ( DOB ) ; Day ( DOB ) ; Year ( now ) ) ; passed = now > thisBD ; age = Year ( now ) - Year ( DOB ) - passed ] ; Case ( age > 17 ; TextColor ( age & " years old" ; RGB ( 0 ; 255 ; 0 ) ) ; age = 17 ; TextColor ( age & " years old" ; RGB ( 240 ; 174 ; 0 ) ) ; TextColor ( age & " too young!" ; RGB ( 255 ; 0 ; 0 ) ) ) ) Then on your DOB field, attach this validation: GetAsNumber ( aboveAgeCalc ) > 16 Since you didn't indicate the message you wanted, you can adjust it. But I wanted you to see that whatever message text you put into this age calc can be ignored by the validation by using GetAsNumber() ... LaRetta :wink2:
July 31, 200619 yr I entered your code into FM to give it a whirl and to fully understand it. Works very nice (after I made a small change). Change "passed = now > thisBD ;" to "passed = now < thisBD ;" :P
August 1, 200619 yr Yes, silly error on my part. I made the same mistake on another forum today - identical calc. I must be due for vacation. :P
Create an account or sign in to comment