日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

html自动年份版权,如何将html5日期输入限制在合理的年份

發布時間:2025/3/15 编程问答 18 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html自动年份版权,如何将html5日期输入限制在合理的年份 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

html5 input type ='date'用于Chrome中以輸入最新免費jqgrid中的日期。如何將html5日期輸入限制在合理的年份

它允許輸入5位數字的日期,如20161。 如何解決此問題,以便只能輸入范圍為 1940 .. current year + 2 years的日期?

免費jqGrid的日期欄模板:

// search template from http://stackoverflow.com/questions/8710162/jqgrid-calendar-icon-not-showing-up-in-inline-editing-mode

var DateTemplate = {

sorttype: 'date',

formatter: 'date',

formatoptions: {

srcformat: "Y-m-d",

//added according to http://www.trirand.com/blog/?page_id=393/bugs/date-problem

reformatAfterEdit: true

},

editoptions: {

maxlength: 10,

size: 10,

dataInit: initDateEdit

},

editable: true,

searchoptions: {

clearSearch: false,/

// for the searching toolbar:

// http://stackoverflow.com/questions/34475094/how-to-make-html5-date-field-in-search-toolbar-to-respect-column-width

attr: { size: 10, type: "date", style: "width:11em;" },

sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge'],

dataInit: initDateHtmlSearch,

size: 11 // for the advanced searching dialog

}

};

// http://stackoverflow.com/questions/29194381/how-to-use-native-datapicker-in-both-form-and-row-editing-in-free-jqgrid

// http://stackoverflow.com/questions/26040738/how-to-use-input-type-date-for-date-column-in-jqgrid

var initDateEdit = function (elem, options) {

// we need get the value before changing the type

var orgValue = $(elem).val(), newformat,

cm = $(this).jqGrid("getColProp", options.name);

$(elem).attr("type", "date");

if ((typeof Modernizr !== "undefined" && !Modernizr.inputtypes.date) || $(elem).prop("type") !== "date") {

$(elem).attr("type", "text"); // !!! important to make saving works correctly

$(elem).css({ width: "8em" }).datepicker({

autoSize: true,

changeYear: true,

changeMonth: true,

showButtonPanel: true,

showWeek: true

});

} else {

// convert date to ISO

if (orgValue !== "") {

newformat = cm.formatoptions !== null && cm.formatoptions.newformat ?

cm.formatoptions.newformat :

$(this).jqGrid("getGridRes", "formatter.date.newformat");

$(elem).val($.jgrid.parseDate.call(this, newformat, orgValue, "Y-m-d"));

}

$(elem).css({ width: "10em" });

}

};

2016-08-26

Andrus

+0

使用'min'和'max'屬性來指定終止日期 –

總結

以上是生活随笔為你收集整理的html自动年份版权,如何将html5日期输入限制在合理的年份的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。