我正在使用Trent Richardson 的 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);
}
}
});