在文本框中添加日期 [英] Add day to date in textbox

查看:127
本文介绍了在文本框中添加日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我想在文本框中添加日期。

i页面上有asp.net文本框控件约会。

Javascript或jquery两种解决方案对我都没问题。



问候,

SUNIL MALI。

解决方案

Hi Sunil,





使用以下代码:这是jquery代码

  //  当前日期是2013年5月20日 
var currentDate = new 日期();
// 我在当前日期添加了5天。新日期为2013年5月25日
currentDate.setDate(currentDate.getDate()+ 5);
// 我已将新日期设置为文本框,例如txtDate是文本框或日期选择器的ID


' #txtDate')。val(currentDate);





以下是更新的解决方案

如果文本框的值类似于05/21/2013​​,您应该可以使用:

  var  currentDate =  new  日期


' #<%= txtDate.ClientID%>')。val ());
currentDate.setDate(currentDate.getDate()+ 1);
// 输出是05/22/2013
console .log(currentDate);





谢谢,

Imdadhusen


Hello all,

I want to add day to date in textbox.
i have asp.net textbox control on page which has date.
Javascript or jquery both solutions are ok to me.

Regards,
SUNIL MALI.

解决方案

Hi Sunil,


Use following code: this is jquery code

//Current date is 20 May 2013
var currentDate = new Date();
//I have added 5 days in current date. New date is 25 May 2013
currentDate.setDate(currentDate.getDate()+5);
//I have setting new date to textbox e.g. txtDate is a id of textbox or date picker


('#txtDate').val(currentDate);



Following are updated solution
If the value of the textbox is something like "05/21/2013", you should be able to use:

var currentDate = new Date(


('#<%= txtDate.ClientID %>').val()); currentDate.setDate(currentDate.getDate()+1); //Output is 05/22/2013 console.log(currentDate);



Thanks,
Imdadhusen


这篇关于在文本框中添加日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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