Example of jquery easyui's determination for a start time earlier than the end time

Source: Internet
Author: User

For more information about how to determine whether the start time is earlier than the end time, see ValidateBox in jquery easyui.
Okay! Directly Add code
Copy codeThe Code is as follows:
View content: By Time:
<Input class = "easyui-datetimebox" style = "width: 180px" id = "start2" value = "$ {startTime}">
<Span class = "newfont06"> to </span>
<Input class = "easyui-datetimebox" style = "width: 180px "id =" end2 "value =" $ {endTime} "validType =" md ['# start2'] ">
<Input name = "Submit4" type = "button" class = "right-button02" value = "query" onclick = "query2 ('$ {pid }'); "id =" query "/>

Copy codeThe Code is as follows:
<Script type = "text/javascript">
Var varify; // used for query and verification. Check whether the start time is earlier than the end time.
Function query2 (pid ){
If (varify ){
StartTime2 = $ ('# start2'). datetimebox ('getvalue ');
EndTime2 = $ ('# end2'). datetimebox ('getvalue ');
Window. location. href = "listPagingArticle? Pid = "+ pid +" & pageNumber = 1 & start = "+ startTime2 +" & end = "+ endTime2;
} Else {
$. Messager. alert ('Warning ', 'end time must be later than starttime', 'warning ');
}

}
$. Fn. datebox. defaults. formatter = function (date) {// time format conversion

Var y = date. getFullYear ();
Var m = fullnum (date. getMonth () + 1 );
Var d = fullnum (date. getDate ());
Return y + '-' + m + '-' + d;
};
Function fullnum (obj) {// for conversions in the format of less than 10 months, because the Timestamp conversion must be in the format of 2013-01-04
If (Number (obj) <10 ){
Return '0' + obj;
} Else {
Return obj;
}}

$. Extend ($. fn. validatebox. defaults. rules, {// The verification start time is earlier than the end time
Md :{
Validator: function (value, param ){
StartTime2 = $ (param [0]). datetimebox ('getvalue ');
Var d1 = $. fn. datebox. defaults. parser (startTime2 );
Var d2 = $. fn. datebox. defaults. parser (value );
Varify = d2> d1;
Return varify;

},
Message: 'The End Time must be later than the start time! '
}
})
</Script>

Related Article

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.