问题描述
好了,
我试着去把日期选取器ASP.net形式。
Im trying to put Date Picker on ASP.net form..
我看到这个code能做到这一点。
I saw that this code can do it..
<script>
$(function() {
$( "#<%= txtDate.ClientID %>" ).datepicker();
});
</script>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtDate" runat="server" />
</div>
</form>
我只是想知道如何在这个应用验证,以及如何显示错误消息..?
Im just wondering how to apply validations on this and how display the error messages..?
验证,如格式,如果我把2日,第1和LT;第2 ..和日期>今天等。
Validations such as format, if i put 2 dates, 1st < 2nd.. and Date>Today etc..
很新的JQuery的,任何帮助将是AP preciated!
Very new to JQuery, any help would be appreciated!
推荐答案
我拿出我的code这一点。在code是自我解释,如果你知道的jQuery / JavaScript的。
I pulled out my code for this. The code is self explanatory if you know jQuery/Javascript.
var dateToday = new Date();
var fromDate = (dateToday.getMonth() + 1) + "/" + dateToday.getDate() + "/" + dateToday.getFullYear()
var toDate = (dateToday.getMonth() + 1) + "/" + dateToday.getDate() + "/" + dateToday.getFullYear()
//初始化寄件者
// Initialize FromDate
$('#datepicker1').datepicker({
todayBtn: "linked",
multidate: false,
autoclose: true,
todayHighlight: true
});
//处理寄件者点击
// Handle fromDate Click
$('#datepicker1').datepicker('setDate', fromDate);
$('#datepicker1').datepicker().on('changeDate', function (e) {
fromDate = $('#datepicker1').val().toString();
if (fromDate > toDate) {
toDate = fromDate;
$('#datepicker2').datepicker('setDate', toDate);
}
});
//初始化TODATE
// Initialize toDate
$('#datepicker2').datepicker({
todayBtn: "linked",
multidate: false,
autoclose: true,
todayHighlight: true
});
//处理TODATE点击
//Handle toDate Click
$('#datepicker2').datepicker('setDate', toDate);
$('#datepicker2').datepicker().on('changeDate', function (e) {
toDate = $('#datepicker2').val().toString();
if (toDate < fromDate) {
fromDate = (new Date(toDate).getMonth() + 1) + "/01/" + new Date(toDate).getFullYear();
$('#datepicker1').datepicker('setDate', fromDate);
}
});
我忘了提,我用这个的
这篇关于JQuery的的DatePicker的ASP.net的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!