bsky
bsky

Reputation: 20222

Rails - date input, allow only weekdays

I have a form which has a field of type Date. The following line creates an input for the field, where the user can choose the date.

<%= f.date_select :start_date %>

How can I make it display only weekdays as input options?

Upvotes: 0

Views: 486

Answers (1)

MarsAtomic
MarsAtomic

Reputation: 10673

It's not possible to do what you want with a date_select helper. You have two alternatives (and one isn't really an alternative):

1) Write a validation in the model that fails if the date selected is not a weekend; or

2) Use a JavaScript date picker (like jQuery DatePicker), which is the only real solution. You can disable specific days or categories of days with DatePicker.

Upvotes: 1

Related Questions