Jump to content

message in cal field


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

Recommended Posts

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.

Link to comment
Share on other sites

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:

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This topic is 5605 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
 Share

×
×
  • Create New...

Important Information

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