# Validation of date\_select

**URL:** <https://www.ruby-forum.com/t/validation-of-date-select/137288>\
**Category:** Ruby\
**Created:** [May 11, 2008, 1:32pm UTC](https://www.ruby-forum.com/t/validation-of-date-select/137288 "2008-05-11T13:32:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dummschwaetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dummschwaetz](https://www.ruby-forum.com/u/dummschwaetz)\
**Post date:** [May 11, 2008, 1:32pm UTC](https://www.ruby-forum.com/t/validation-of-date-select/137288/1 "2008-05-11T13:32:47Z")

</div>

I’m new to ror. I need to check a date in a form.  
I’m validating if the datefields (I used a date\_select) are empty. In  
case they are not all three fiels (d, m, y) get a red background, but  
only the selectfield for the day gets red. How can I change the  
background of all selectfields?  
In a second step I check if the date is allowed (31th of february  
isn’t). Is it possible to change in this case the backgroundcolor of the  
field for the day and the month?  
thanks in advance

---

<div class="post-metadata">

**Author:** ![dummschwaetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dummschwaetz](https://www.ruby-forum.com/u/dummschwaetz)\
**Post date:** [May 11, 2008, 1:50pm UTC](https://www.ruby-forum.com/t/validation-of-date-select/137288/2 "2008-05-11T13:50:59Z")

</div>

-----BEGIN PGP SIGNED MESSAGE-----  
Hash: SHA1

Kim Q. wrote:  
| I’m new to ror. I need to check a date in a form.  
| I’m validating if the datefields (I used a date\_select) are empty. In  
| case they are not all three fiels (d, m, y) get a red background, but  
| only the selectfield for the day gets red. How can I change the  
| background of all selectfields?  
| In a second step I check if the date is allowed (31th of february  
| isn’t). Is it possible to change in this case the backgroundcolor of the  
| field for the day and the month?  
| thanks in advance

A look into the Rails API documentation reveals this:

> **[ActiveRecord::Validations](https://api.rubyonrails.org/classes/ActiveRecord/Validations.html)**
>
> Active Record Validations Active Record includes the majority of its validations from ActiveModel::Validations all of which accept the :on argument to define the context where the validations are act.

Though, you might want to ask the Rails community about this and Other  
Rails related questions:

> **[Community](https://rubyonrails.org/community)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

They usually answer faster.

* * *

Phillip G.  
Twitter: [twitter.com/cynicalryan](http://twitter.com/cynicalryan)  
Blog: [http://justarubyist.blogspot.com](http://justarubyist.blogspot.com)

~ “Dad buried in landslide! Jubilant throngs fill streets! Stunned  
father inconsolable - demands recount!” – Calvin  
-----BEGIN PGP SIGNATURE-----  
Version: GnuPG v1.4.8 (MingW32)  
Comment: Using GnuPG with Mozilla - [http://enigmail.mozdev.org](http://enigmail.mozdev.org)

iEYEARECAAYFAkgm3W8ACgkQbtAgaoJTgL9w4wCfTJyHdb5U1kCQ9kJPqHH1Akv0  
g+YAni0NQtunQFU4636Yz6Gb5cBB4hF/  
=Beru  
-----END PGP SIGNATURE-----

---

<div class="post-metadata">

**Author:** ![dummschwaetz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e480ec/32.png) [@dummschwaetz](https://www.ruby-forum.com/u/dummschwaetz)\
**Post date:** [May 11, 2008, 2:18pm UTC](https://www.ruby-forum.com/t/validation-of-date-select/137288/3 "2008-05-11T14:18:27Z")

</div>

Thanks. I’ll post my question there.

> A look into the Rails API documentation reveals this:  
> [http://api.rubyonrails.org/classes/ActiveRecord/Validations.html](http://api.rubyonrails.org/classes/ActiveRecord/Validations.html)
> 
> Though, you might want to ask the Rails community about this and Other  
> Rails related questions:  
> [Ruby on Rails — Community](http://www.rubyonrails.com/community)
> 
> They usually answer faster.
