Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6692 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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.

Posted

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:

Posted

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

Posted

Yes, silly error on my part. I made the same mistake on another forum today - identical calc. I must be due for vacation. :P

This topic is 6692 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.