Search code examples
ruby-on-railsruby-on-rails-4jquery-pluginsdatetimepicker

Is there a way to clear value in a particular field after failed submission?


I have separate date and time field: ie Start date , Start time, End date, End time. Im using jquery time picker, and date pair plugin.

If I fill either one of start date or end date, they will both be filled in with values automatically. And same in Start time and end time, they will be both filled in. So I am testing these scenarios:

  1. Start date and End date are filled in with values. Start time and end time are blank. After clicking submit, I have the right error, no problem, but it is returning the start time and end time with values. which I dont want.

  2. Start time and End time are filled in with values. Start date and end date are blank. After clicking submit, ofc I have the right error, no problem, but it is returning the start date and end date with values (ie: the date today). which I dont want.

I have a feeling this is the normal behaviour of jquery plugin time picker after failed submission, it will automatically set default values if left blank in first submission.

This is not a big deal to be honest, but Im just concern for better UX.

PLease help.


Solution

  • I was able to solve it by simple using a jquery.