3

I am trying to include a time field that has a min and max allowed range, but that is prepopulated with a value from the database that might be incorrect (out of range). When it's incorrect, I show an error message to the user, so they can change it. I'm using keepInvalid and useCurrent so that the incorrect value doesn't get wiped out or changed, but the problem is that when they click to pop up the widget, none of the values are changeable. The time just says 12:00:00 and won't let you use the arrows to change it. Removing keepInvalid and useCurrent makes the time changeable again, but it also changes the incorrect value to the min value automatically.

Can anyone tell me what I am doing wrong?

<div class="formTimelineStartTime">
    <div class="form-group control-group">
        <div class="controls">
            <div class="input-group date">
                <input type="text" id="fldTBStartTime1" class="form-control input-sm" value="12:45:45 PM" readonly="readonly"/>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
  $(function () {
      $('#fldTBStartTime1').datetimepicker({
          useCurrent: false,
          keepInvalid: true,
          format: 'hh:mm:ss A',
          minDate: '7/6/2016 12:08:38 PM',
          maxDate: '7/6/2016 12:30:14 PM',
          ignoreReadonly: true
      });
  });
</script>
Tonya Abna
  • 121
  • 1
  • 7

1 Answers1

0

Well, i have this same problem but in a different manor

$('#date').datetimepicker({
    format:'MMM-DD',
    ignoreReadonly:true,
    viewMode:'months', 
    minDate: new Date(year, 00, 01, 00, 00),
    maxDate: new Date(year, 12, 00, 00, 00),
    showClear:true,
    useCurrent: false,
    keepInvalid:true
});

I use it like this

But when it is out of range the value gets removed if keepInvalid:false because it is an invalid date.

If you use it with keepInvalid:true then it wont let you pick because the year was already picked and invalid from out of range, you have to put the full format to see what is happening.

Crustamet
  • 104
  • 1
  • 11