How to validate a date_select field

View [actually in a partial]...

      <%= date_select 'contract_payment', 'credit_card_expiration_date',
      { :order => [:month, :year], :start_year => 2006, :end_year => 2020,
:use_month_numbers => true,
      :discard_day => true, :include_blank => true } %>

Model :

validates_presence_of :credit_card_expiration_date,

This is not right. The View renders correctly (minus the hard-coded
2006... not sure yet how to replace that].

I want to make the month and year [sub-]fields required. I also want
them to be greater than today. The "validates_presence_of" doesn't
handle both the month and year correctly.

I would really appreciate an example.


Hi, you can try using the following:



Good luck,