- Posts: 50
- Thank you received: 0
Validation of date format
- lorna guttormson
- Topic Author
- Offline
- Senior Member
Less
More
2 months 1 week ago #169182
by lorna guttormson
Validation of date format was created by lorna guttormson
What is the best way to validate a date field? - and hopefully give a guideline to the user. What I have tried - set as text and display a placeholder - user can still enter anything. Set as Date - validate with 'validate[required,minSize[10]]'. Cannot then present a placeholder and if user enters dec 3,1965 - it comes through as 2029-07-17. What I would like is yyyy-mm-dd but I have found that if the user enters dd-mm-yyyy - it will get correctly flipped to y-m-d which would be fine except for the other possible incorrect entries that get so badly interpreted.
Please Log in or Create an account to join the conversation.
- Tuan Pham Ngoc
- Offline
- Administrator
2 months 6 days ago #169194
by Tuan Pham Ngoc
Replied by Tuan Pham Ngoc on topic Validation of date format
Why don't you create a Date field instead of Text field ?
Tuan
Tuan
Please Log in or Create an account to join the conversation.
- lorna guttormson
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 50
- Thank you received: 0
2 months 6 days ago - 2 months 6 days ago #169200
by lorna guttormson
Replied by lorna guttormson on topic Validation of date format
I have tried setting it as date and, as mentioned above, when I "Set as Date - validate with 'validate[required,minSize[10]]'. Cannot then present a placeholder and if user enters dec 3,1965 - it comes through as 2029-07-17." I cannot see how one can validate a date field or ensure it comes through properly.
Here is the setting when I set it as Date - and which allows something like 'dec 3,1965' and
Here is the setting when I set it as Date - and which allows something like 'dec 3,1965' and
Last edit: 2 months 6 days ago by lorna guttormson. Reason: to add an attachment and more information
Please Log in or Create an account to join the conversation.
- lorna guttormson
- Topic Author
- Offline
- Senior Member
Less
More
- Posts: 50
- Thank you received: 0
2 months 5 days ago #169207
by lorna guttormson
Replied by lorna guttormson on topic Validation of date format
I have found the built-in validates datFormat and dateBefore but haven't been able to figure out the exact inpout format. What I have now is dateFormat:'dob','Y-m-d'|dateBefore:'dob';date(). The dateFormat alone works but the error message is in the bottom right - not linked to the field. The user would likely not notice. The DateBefore didn't seem to be recognized and now I get you exceeded the number of form submissions limit . Hopefully I can continue later when the security time limit runs out. I would really appreciate if you could give me the proper syntax for this so I can get on with my development.
Please Log in or Create an account to join the conversation.
Support
Documentation
Information
Copyright © 2024 Joomla Extensions by Joomdonation. All Rights Reserved.
joomdonation.com is not affiliated with or endorsed by the Joomla! Project or Open Source Matters.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.
The Joomla! name and logo is used under a limited license granted by Open Source Matters the trademark holder in the United States and other countries.