datetime - Rails form: auto-set a future date based on date set -


my rails form asks users input start date event, , end date same event. setting default start date time.now

is possible user can ever choose end date occurs on or after start date? (so when change start date, end date auto-updates)?

my events controller:

def new     @event = event.new(params[:event])      # set date_start field today's date     @event.date_start = time.now     @event.date_end = @event.date_start      end 

form (shortened...)

<%= form_for(@event) |f| %>       <%= f.label :date_start, "start date" %>     <%= f.date_select(:date_start, :prompt => { :day => 'day', :month => 'month', :year => 'year' }) %>                   <%= f.label :time_start, "start time" %>     <%= f.time_select :time_start, { :minute_step => 5 } %>                                    <%= f.label :date_end, "end date" %>     <%= f.date_select(:date_end, :prompt => { :day => 'day', :month => 'month', :year => 'year' }) %>    <% end %> 

you'll end using javascript this. might using javascript datapicker help. there number of them out there , allow ranges, here's example:

http://api.jqueryui.com/datepicker/#option-mindate


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Socket.connect doesn't throw exception in Android -

SPSS keyboard combination alters encoding -