0

I am providing the calendar option for user to select date. But I want to restrict a user entering date using keyboard. Does anyone know how to do that?

This is the code that I am using for calendar functionality -

form do |f|
 f.inputs do
  f.input :expires_at, as: :datepicker, default: Date.today + 1.month, selected: Date.today + 1.month, include_blank: false, datepicker_options: { min_date: Date.current + 1.day, max_date: Date.current + 12.months }
 end
  
 f.actions
end
User
  • 169
  • 1
  • 11
  • This is a really bad idea and iyour approach is obsolete. Use the native `` supported by all modern browsers. You're going to annoy the hell out of your users and create accessibility problems. https://www.w3.org/TR/wai-aria-practices/examples/dialog-modal/datepicker-dialog.html – max Jan 20 '22 at 15:55
  • 1
    Trust me. Your users would much rather have the native controls made for their device then some cobbled together js crap that doesn't fit on a mobile screen. – max Jan 20 '22 at 16:00

1 Answers1

0

Have a look at this comment. You can add readonly: true attribute to your input. It will only allow users to choose your date from the picker.

Marelons
  • 150
  • 6