jQuery日期选择器的默认值 [英] Default value for jquery date picker

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

问题描述

我对jQuery UI日期选择器有一些疑问.

I have some questions regarding jQuery UI date picker.

1-是否可以使用默认值?我想做的是用今天的日期预填充我的输入文本类型.

1 - Is there an option to have a default value? What I am trying to do is pre-filled my input text type with today's date.

2-如果我将type ="Date"代替type ="Text",然后在上面使用jquery时间选择器,则选择日期时会出现此错误.

2 - If I put the type = "Date" instead of type = "Text" and then use jquery time picker on it, I get this error when I select the date.

 The specified value '02/18/2015' does not conform to the required format, 'yyyy-MM-dd.'

我该如何解决?

推荐答案

要创建日期选择器并设置日期.您可以通过"new Date()"分配今天的日期.您可以设置输入type=texttype=date.

$('.datepicker').datepicker({ 
     dateFormat: 'dd-mm-yy'
     }).datepicker("setDate", new Date());

这篇关于jQuery日期选择器的默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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