本文介绍了如何在单击提交按钮时更改datepicker日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个datepicker文本框和提交按钮.datepicker文本框默认显示今天的日期。单击提交按钮,我想使用Jquery在datepicker文本框中设置另一个日期。



似乎jquery函数工作正常。我可以更改date.But它会自动将日期更改为默认日期,该日期位于datepicker文本框中(初始值)。



请帮忙!



我尝试了什么:



JQuery

I have a datepicker textbox and submit button.The datepicker textbox defaultly shows the todays date.On click of submit button, I would like to set another date in datepicker textbox using Jquery.

It seems the jquery function working is fine.I am able to change the date.But It is automatically changing the date to default date which is in the datepicker textbox(inital value).

Please help!

What I have tried:

JQuery

function ValidateDate() {
    var sDate = $('#ScheduledDate').val();
    var sDateTo = $('#ScheduledDateTo').val();


    if (sDate == undefined || sDate == '') {
        alert("Please enter Scheduled Date.");
        return false;
    }
    else {

        var todaydate = $('#ScheduledDate').val();
        $('#ScheduledDateTo').datepicker('setDate', todaydate);
        return true;
    }


}





.cshtml



.cshtml






@Html。标签(预定日期:,新{@class =col-md-3 control-label})


@Html.Label("Scheduled Date:", new { @class = "col-md-3 control-label" })


@Html.TextBox(ScheduledDate,DateTime.Now.ToShortDateString(),new {@class =form-control datepicker})


@Html.TextBox("ScheduledDate", DateTime.Now.ToShortDateString(), new { @class = "form-control datepicker" })









@ Html.TextBox(ScheduledDateTo,DateTime.Now.ToShortDateString(),new { @class =form-control datepicker})


@Html.TextBox("ScheduledDateTo", DateTime.Now.ToShortDateString(), new { @class = "form-control datepicker" })






按日期搜索


Search by Date




推荐答案




这篇关于如何在单击提交按钮时更改datepicker日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 23:51