Date Validation

6 years 4 months ago - 6 years 4 months ago #300045 by edmundcheong
Date Validation was created by edmundcheong
I have created a date field called cb_dateofbirth and I want to validate the date field (cb_dateofbirth) to be smaller than today's date (or perhaps a date stored in one of the other fields?).. therefore, I configured the cb Code Field (under the field integrations) to have the following codes below. Is this how it should actually work?

Attachments:

Please Log in to join the conversation.

6 years 4 months ago #300052 by krileon
Replied by krileon on topic Date Validation
If this is date of birth for the user themselves you don't need that. Suggest just using the following parameters on the date field to restrict how old they can select.

Minimum Year: - 100
Maximum Year: -13

That should limit them to the age range of 13 - 100. Nothing else will be selectable. Both parameters can be found under Parameters > Validation of your date field.

If you still insist on custom validation then some comments regarding your code is it's not valid PHP or substitutions. The code field simple takes your string of text, converts to PHP, and executes it; please also read the parameter description carefully regarding what values your code should return for validation purposes.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 4 months ago #300123 by edmundcheong
Replied by edmundcheong on topic Date Validation

krileon wrote: If this is date of birth for the user themselves you don't need that. Suggest just using the following parameters on the date field to restrict how old they can select.

Minimum Year: - 100
Maximum Year: -13

That should limit them to the age range of 13 - 100. Nothing else will be selectable. Both parameters can be found under Parameters > Validation of your date field.


I know about this feature.. I am actually prototyping a claims application and I would require that the date validation to be dynamic.

If you still insist on custom validation then some comments regarding your code is it's not valid PHP or substitutions. The code field simple takes your string of text, converts to PHP, and executes it; please also read the parameter description carefully regarding what values your code should return for validation purposes.


Is there a code field sample on the demo site which I can study as a sample?

Please Log in to join the conversation.

6 years 4 months ago #300134 by krileon
Replied by krileon on topic Date Validation

I know about this feature.. I am actually prototyping a claims application and I would require that the date validation to be dynamic.

Those parameters are dynamic if you use -NUMBER or +NUMBER usages.

Is there a code field sample on the demo site which I can study as a sample?

For simple display of PHP, yes. For validation, no. Code Validation just executes your supplied PHP where you'd return a true or false if the value is valid; please be sure to read the parameter descriptions carefully.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 years 4 months ago #300172 by edmundcheong
Replied by edmundcheong on topic Date Validation

For simple display of PHP, yes. For validation, no. Code Validation just executes your supplied PHP where you'd return a true or false if the value is valid; please be sure to read the parameter descriptions carefully.


Been looking for it. Sorry but can you show me where to find the sample on the demo site? Thanks.

Please Log in to join the conversation.

6 years 4 months ago #300175 by krileon
Replied by krileon on topic Date Validation
There is no example for what you're trying to do on our demo site. There is only a simple example of outputting PHP as a field value, which you can review the cb_codefield1 field for in the backend. What you're needing to do though is to write custom PHP to compare the [value] against the current date using the Code Validation feature of CB Code Field. This is added by editing your field then review the parameters under the Integrations > CB Code Field tab.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.663 seconds