jQuery datetimepicker 초기화

3223 단어 javascript
/*        */
    initDateTimePicker(s, e) {
        jQuery.datetimepicker.setLocale('ch');
        jQuery(function(){
            jQuery(s).datetimepicker({
                format: 'Y-m-d H:i',
                onShow:function( ct ){
                    this.setOptions({
                        maxDate: jQuery(e).val()?jQuery(e).val():new Date(),
                    });
                },
                validateOnBlur:false,
                onChangeDateTime: function(current_time,$input) {
                    var endTime = new Date($(e).val());
                    if(current_time && endTime) {
                        current_time.setSeconds(0);
                        current_time.setMilliseconds(0);
                        if(current_time > new Date() || current_time.getTime() >= endTime.getTime()) {
                            $(s).val("");
                            Messenger().post({
                                message: '               ,     !',
                                type: 'error',
                                showCloseButton: true,
                                hideAfter: 2
                            });
                            Messenger({
                                extraClasses: 'messenger-fixed messenger-on-top'
                            });
                        }
                    }  
                }
            });
            jQuery(e).datetimepicker({
                format: 'Y-m-d H:i',
                onShow:function( ct ){
                    this.setOptions({
                        minDate: jQuery(s).val()?jQuery(s).val():false,
                        maxDate: new Date()
                    });
                },
                validateOnBlur:false,
                onChangeDateTime: function(current_time,$input) {
                    var startTime = new Date($(s).val());
                    if(current_time && startTime) {
                        current_time.setSeconds(0);
                        current_time.setMilliseconds(0);
                        if(current_time > new Date() || current_time.getTime() <= startTime.getTime()) {
                            $(e).val("");
                            Messenger().post({
                                message: '                 ,     !',
                                type: 'error',
                                showCloseButton: true,
                                hideAfter: 2
                            });
                            Messenger({
                                extraClasses: 'messenger-fixed messenger-on-top'
                            });
                        }
                    } 
                }
            });
        });
    }


 
  

initDateTimePicker("#start-time-info", "#end-time-info");


https://github.com/xdan/datetimepicker

좋은 웹페이지 즐겨찾기