function add() {
var mon = parseInt($("#<%=txtStime.ClientID %>").val());
var time = new Date(Date.parse($("#<%=txtBeginTime.ClientID %>").val().replace(/\-/g, "\/")));
var times = setTime(time, { type: 'M', value: mon });
$("#<%=txtEndTime.ClientID %>").val(times);
}
function setTime(d, opts) {
if (!d) return;
var t = opts.type || 'd',
v = opts.value || 1;
switch (t) {
case 'y':
d.setFullYear(d.getFullYear() + v);
break;
case 'M':
d.setMonth(d.getMonth() + v);
break;
case 'd':
d.setDate(d.getDate() + v);
break;
case 'h':
d.setHours(d.getHours() + v);
break;
case 'm':
d.setMinutes(d.getMinutes() + v);
break;
case 's':
d.setSeconds(d.getSeconds() + v);
break;
}
return d.toLocaleString().replace(/年|月/g, '-').replace('日', '');
}<pre name="code" class="html"> <table width="100%" class="table" cellspacing="0" cellpadding="0">
<tr>
<td width="9%">
试用期限
</td>
<td>
<asp:TextBox ID="txtStime" οnblur="add();" Width="200px" CssClass="text" runat="server"></asp:TextBox><p>个月</p>
</td>
<td width="9%">
试用开始时间
</td>
<td>
<asp:TextBox ID="txtBeginTime" Width="200px" runat="server"></asp:TextBox>
</td>
<td width="9%">
试用结束时间
</td>
<td>
<p style="text-align:left">
<asp:TextBox ID="txtEndTime" Width="200px" runat="server"></asp:TextBox>
</p>
</td>
</tr>
</html>
Jquery时间求和 C#
最新推荐文章于 2018-12-05 10:37:30 发布