Jquery 1.32 datepicker enhanced Edition

Source: Internet
Author: User

Add some JSCodeImplement the "clear" button

 

< Script Type = " Text/JavaScript " >
$ (Function (){
$ ( " # Datepicker " ). Datepicker ({closetext: ' X ' , Showbuttonpanel: True , Showclearbutton: True , Mindate: New Date ( 2009 , 7 , 10 )});
});
</ Script >

 

 

Description of automatic date range ban:

 

< 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. Replace ( ' - ' , ' , ' )));}
});
});
</ Script >

 

ProgramDownload the source code and more examples of datepicker usage:

/Files/Yasin/jquery_datepicker.zip

 

Datepicker official address:

Http://docs.jquery.com/UI/API/1.7/Datepicker#method-option

 

 

The date format is automatically verified after the focus is lost

 

_ Doblur: function ( Event )
{
VaR Inst = $. Datepicker. _ getinst ( Event . Target );

If(Inst. Input [0]. Value. Length=0)//Allowed to be empty
Return;

VaR Reg =/^ (\ D { 4 })(\ /|- ) (\ D { 1 , 2 })\ 2 (\ D { 1 , 2 }) $ / ;
VaR arr = Inst. Input [ 0 ]. Value. Match (REG)
If (ARR = Null )
{
Alert ( " Incorrect time format. Enter \ n in the format, for example, 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 ( " Incorrect time format. Enter \ n in the format, for example, 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 ;
}
},

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.