Mobiscroll日期插件使用


  • 相關資源
  1. 官方幫助文檔:https://docs.mobiscroll.com/3-0-1
  • 導入資源文件
<link href="${webRoot}/template/green/wap/module/member/medicinebox/statics/css/mobiscroll.css" type="text/css" rel="stylesheet" />
<link href="${webRoot}/template/green/wap/module/member/medicinebox/statics/css/mobiscroll_date.css" type="text/css" rel="stylesheet" />

<script src="${webRoot}/template/green/wap/module/member/medicinebox/statics/js/jquery.min.js" type="text/javascript"> </script>
<script src="${webRoot}/template/green/wap/module/member/medicinebox/statics/js/mobiscroll_date.js" type="text/javascript"> </script>
<script src="${webRoot}/template/green/wap/module/member/medicinebox/statics/js/mobiscroll.js" type="text/javascript"> </script>

  

  • 設置日期輸入框
<input id="mobiscroll_input" style="width: 0rem;">

  

  • 初始化日期插件
function initMobiscroll(){
    var currYear = (new Date()).getFullYear();
    var opt={};
    opt.date = {
        preset : 'date',
        onSelect:function(valueText,inst){
            $("#validity_text").text(valueText);
            $("#drug_effective_time_str_input").val($.trim(valueText));
        },
        onBeforeShow: function (event, inst) {
            var validity = $.trim($("#validity_text").text()).split("-");
            if(!isEmpty(validity)){
                $('#mobiscroll_input').mobiscroll('setDate', new Date(validity[0], validity[1] - 1, validity[2]));
            }
        }
    };
    opt.datetime = {preset : 'datetime'};
    opt.time = {preset : 'time'};
    opt.default = {
        theme: 'android-ics light', //皮膚樣式
        display: 'modal', //顯示方式 
        mode: 'scroller', //日期選擇模式
        dateFormat: 'yyyy-mm-dd',
        lang: 'zh',
        showNow: true,
        nowText: "今天",
        startYear: currYear - 50, //開始年份
        endYear: currYear + 10 //結束年份
    };

    $("#mobiscroll_input").mobiscroll($.extend(opt['date'], opt['default']));
}

 歡迎轉載,轉載必須標明出處


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM