文本输入字段为jQuery datepicker默认日期 [英] text input field as jQuery datepicker default date

查看:179
本文介绍了文本输入字段为jQuery datepicker默认日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery的datepicker的默认日期是当前日期,但是我需要它是从我的 #start_date 输入字段中预填充的日期。



这是我现在的位置,但它不起作用。

  var start_date = $('#start_date')。val(); 
$('。datepicker')。datepicker(option,defaultDate,start_date);



 < input type = textid =start_datename =start_dateclass =datepicker form-control col-sm-6placeholder =Startvalue =<?php(!empty($ row ['start_date']) ?$ row ['start_date']:'');?>> 


解决方案

如果输入字段日期与您在选择日期时输入字段中设置的格式相同,则默认情况下将由Datepicker加载,而不会使用Datepicker intalization。 b
$ b

可能是您的变量$ row ['start_date']显示输入字段中的日期和时间,尝试使用mm / dd / yyyy格式的值,并且应该能够正常工作。 p>

The default date for jQuery's datepicker is the current date, but I need it to be the pre-populated date from my #start_date input field.

This is where I'm at now but it doesn't work.

var start_date = $('#start_date').val();
$('.datepicker').datepicker("option", "defaultDate", start_date);

<input type="text" id="start_date" name="start_date" class="datepicker form-control col-sm-6" placeholder="Start" value="<?php (!empty($row['start_date'])?$row['start_date']:'');?>>

解决方案

if the input field date is the same format which set in the input field when you pick the date, then it will be loaded by Datepicker by default without any javascript code just Datepicker intalization.

may be your variable $row['start_date'] show date and time in input field try to make the value in the format of mm/dd/yyyy and it should work perfectly.

这篇关于文本输入字段为jQuery datepicker默认日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆