Extjs custom validation date Selection Range

Source: Internet
Author: User
Method 1:
 // Custom vtype, validation date Selection Range Ext. Apply (ext. Form. Field. vtypes ,{ // Verification Method Daterange: function (Val, field) {var begindate = Null , // Start date Begindatecmp = Null , // Start date component Enddate = Null , // End date Enddatecmp = Null , // End date component Validstatus = True ; // Verify the status             If (Field. daterange ){ // Obtain the start time                  If (! Ext. isempty (field. daterange. Begin) {begindatecmp = ext. getcmp (field. daterange. Begin); begindate = begindatecmp. getvalue ();} // Obtain the end time                  If (! Ext. isempty (field. daterange. End) {enddatecmp = ext. getcmp (field. daterange. End); enddate = enddatecmp. getvalue ();}} // If one of the seemingly time or end time is null, it passes verification.              If (! Ext. isempty (begindate )&&! Ext. isempty (enddate) {validstatus = begindate <= enddate ;} Return Validstatus ;}, // Verification prompt information Daterangetext: 'Start time cannot be later than end time' }); // Use: {ID: 'Begindate' , Fieldlabel: 'Admission start date' , Daterange: {begin: 'Begindate' , End: 'Enddate' }, // Used for vtype daterange Vtype: 'Daterange' }, {ID: 'Enddate' , Fieldlabel: 'Admission end date' , Daterange: {begin: 'Begindate' , End: 'Enddate' }, // Used for vtype daterange Vtype: 'Daterange' }
 
Method 2:// Set the maximum and minimum values of datefield through the listenerListeners :{'Focal': Function (e) {var endtime = ext. getcmp ('Endtimeid'). Getvalue ();If(Endtime! =''){This. Setmaxvalue (endtime. Format ('Y-m-d'));}}}

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.