1

Trent Richardson の Timepicker プラグインを使用しています。

オプションのタイムピッカー フィールドを持つフォームがあります。フォームがロードされると、これらのフィールドのデフォルト値が設定されます。

timepicker フィールドのデフォルト値を空白に設定する方法を知っている人はいますか?

生成される HTML:

</p><p class="name">
    <input type="hidden" class="datetime_value_fix" value="" id="birthday"/>
    <input type="text" class="form_datetime" name="birthday" value="01/01/1970 01:00 AM"/><label for="birthday">Birthday</label>
</p><div class="item_header">
    <label>Office Hours</label>
</div>
<p class="name">
    <input type="hidden" class="datetime_value_fix" value="" id="start_office"/>
    <input type="text" class="form_time" name="start_office" value="01:00 AM"/><label for="start_office">Start of the day</label>
</p><p class="name">
    <input type="hidden" class="datetime_value_fix" value="" id="end_office"/>
    <input type="text" class="form_time" name="end_office" value="01:00 AM"/><label for="end_office">Gone for the day</label>
</p><p class="name">
    <input type="hidden" class="datetime_value_fix" value="" id="vacation_start"/>
    <input type="text" class="form_date" name="vacation_start" value="01/01/1970"/><label for="vacation_start">Vacation start</label>
</p><p class="name">

JS:

    $('.form_datetime').datetimepicker({ampm: true,hourGrid: 4,minuteGrid: 15, timeFormat: 'hh:mm TT'});
        $('.form_date').datepicker();
        $('.form_time').timepicker({ampm: true, hourGrid: 4,minuteGrid: 15, timeFormat: 'hh:mm TT'});
//attempt to clear out html data being generated by plugin
$('.datetime_value_fix').each(function(){ 
  field_name = $(this).attr('id'); 
  field_value = $(this).val(); 
  $(' :input').each(function(){ 
    if ($(this).attr('name') == field_name){ 
      if ($(this).val() != field_value){ 
        $(this).val(field_value); 
      } 
    } 
  });
4

1 に答える 1