The end date is less than the start date, you always have to code the problem, but it is convenient now, do not need to focus on the details of these issues
The following content is the original address: http://www.cnblogs.com/yasin/archive/2009/07/10/1520736.html
Add some JS code to implement the "clear" button
< script type = "Text/javascript" >
$ (function () {
$ ("#datepicker"). DatePicker ({closetext: ' X ', Showbuttonpanel:true, Showclearbutton:true, Mindate:new Date (20 09, 7, 10)});
});
</script >
Automatic selection of the date period:
< script type = "Text/javascript" >
$ (function () {
$ ("#start-date"). DatePicker (
{onselect:function (Datetext, inst) {$ (' #end-date '). DatePicker (' option ', ' mindate ', new Date (datetext.replace ( ' - ' , ' , ' )));}
});
$ ("#end-date"). DatePicker (
{onselect:function (Datetext, inst) {$ (' #start-date '). DatePicker (' option ', ' maxdate ', new Date (DATETEXT.REPL Ace ('-', ', ')));}
});
});
</script >
Application source code and more DatePicker examples of usage download:
/files/yasin/jquery_datepicker.zip
DatePicker Official Address:
Http://docs.jquery.com/UI/API/1.7/Datepicker#method-option
2009-07-13 increase focus lost after auto-Validate date format
_doblur:function (Event)
{
var inst = $.datepicker._getinst (event. Target);
if (inst.input[0].value.length = = 0)//allow NULL
return;
var reg =/^ (/d{4}) (//|-) (/d{1, 2})/2 (/d{1, 2}) $/;
var arr = inst.input[0].value.match (REG)
if (arr = = null)
{
Alert ("The wrong time format, please fill in format/n as: 2012-12-22");
var today = new Date (); Set to current date
inst.input[0].value = today.getyear () + "-" + (Today.getmonth () + 1) + "-" + today.getdate ();
inst.input[0].focus ();
return;
}
var tempdate = new Date (arr[1],arr[3]-1, arr[4]);
if ((tempdate.getfullyear () = = arr[1] && (tempdate.getmonth () + 1) = = arr[3] && tempdate.getdate () = = arr[4]) = = False)
{
Alert ("The wrong time format, please fill in format/n as: 2012-12-22");
var today = new Date (); Set to current date
inst.input[0].value = today.getyear () + "-" + (Today.getmonth () + 1) + "-" + today.getdate ();
inst.input[0].focus ();
return;
}
},