2
votes

I am using the following code

<%= f.date_select 'event_date', selected: Date.today, :start_year => Date.today.year, :end_year => Date.today.year + 1 %>

I want to ban people from choosing data at a min of 5 days from now. and max of 1 year max. How can i set the date and month?

Or should i do this in model validation?

1

1 Answers

3
votes

From this answer: Rails 4 date_field, min and max year?

You should be able to give the min and max dates:

f.date_select 'event_date', selected: Date.today, min: 5.days.ago, max: 1.year.from_now