regex - Rails - validates_format_of for datetime (mysql format) -
i'm having custom input field in simple_form
user sets datetime bootstrap datetimepicker plugin
= f.input :published_at, as: :date_time_picker
the datetime set in sql format, yyyy-mm-dd hh:ii:ss
now, 'd set validation, check datetime entered in correct format in case user tries type datetime instead of clicking calendar icon , choosing it
validates_format_of :published_at, with: /^((19|20)\\d\\d)-(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01]) /i, allow_nil: true
how can set format of time in case?
Comments
Post a Comment