# Date validations

**URL:** <https://www.ruby-forum.com/t/date-validations/81333>\
**Category:** Rails\
**Created:** [January 7, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/date-validations/81333 "2007-01-07T22:39:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 7, 2007, 10:39pm UTC](https://www.ruby-forum.com/t/date-validations/81333/1 "2007-01-07T22:39:19Z")

</div>

I have two parts of a question. First I have several dates in my app  
which aren’t required, so I don’t think I can use a date\_select right?  
There doesn’t seem to be a way to give the user an option to _not_  
select a date.

So, assuming I need to just give the users a form field, anyone have a  
good piece of code for checking the validity of a date, allowing  
various forms, i.e.:  
12.12.2007  
12/12/2007  
12-12-2007

Any suggestions?

Thanks, Joe.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 7, 2007, 10:43pm UTC](https://www.ruby-forum.com/t/date-validations/81333/2 "2007-01-07T22:43:05Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I have two parts of a question. First I have several dates in my app  
> which aren’t required, so I don’t think I can use a date\_select right?  
> There doesn’t seem to be a way to give the user an option to _not_  
> select a date.
> 
> So, assuming I need to just give the users a form field, anyone have a  
> good piece of code for checking the validity of a date, allowing  
> various forms, i.e.:  
> 12.12.2007  
> 12/12/2007  
> 12-12-2007
> 
> Any suggestions?
> 
> Thanks, Joe.

No No No 🙂

use some javascript to enable or to disable that date select with a  
check box for example, and then use the check box value in the  
controller in order to check if to use the date select value or not.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 7, 2007, 11:22pm UTC](https://www.ruby-forum.com/t/date-validations/81333/3 "2007-01-07T23:22:17Z")

</div>

removed\_email\_address@domain.invalid wrote:

> I have two parts of a question. First I have several dates in my app  
> which aren’t required, so I don’t think I can use a date\_select right?  
> There doesn’t seem to be a way to give the user an option to _not_  
> select a date.
> 
> So, assuming I need to just give the users a form field, anyone have a  
> good piece of code for checking the validity of a date, allowing  
> various forms, i.e.:  
> 12.12.2007  
> 12/12/2007  
> 12-12-2007
> 
> Any suggestions?
> 
> Thanks, Joe.

try this plugin for validation  
[http://svn.viney.net.nz/things/rails/plugins/validates\_date\_time/](http://svn.viney.net.nz/things/rails/plugins/validates_date_time/)
