2019年1月9日 星期三

jqueryui datepicker 限制 range 在六個月內


$("#shipping_startdate").datepicker({
dateFormat:"yy-mm-dd",
onClose: function( selectedDate ) {

var date = new Date(Date.parse(selectedDate.replace(/-/g,"/")));
var newdate = new Date(date.setMonth(date.getMonth()+6));

$( "#shipping_endate" ).datepicker( "option", "minDate", selectedDate );
$( "#shipping_endate" ).datepicker( "option", "maxDate", formatDate(newdate) );
}
});
$("#shipping_endate").datepicker({
dateFormat:"yy-mm-dd",
onClose: function( selectedDate ) {
var date = new Date(Date.parse(selectedDate.replace(/-/g,"/")));
var newdate = new Date(date.setMonth(date.getMonth()-6));
$( "#shipping_startdate" ).datepicker( "option", "minDate", formatDate(newdate) );
$( "#shipping_startdate" ).datepicker( "option", "maxDate", selectedDate );
}
});


有點小小麻煩所以做個紀錄

2017年10月19日 星期四

jquery-lang-js 翻譯檔裡面若有 '< br >' 無法顯示出來

所以我改寫了一些東西

$(function () {
// Setup data on the language items
self._start();

// Check if the current language is not the same as our default
if (currentLang && currentLang !== self.defaultLang) {
// Switch to the current language
self.change(currentLang);
}
self.parseHTML();
});

$(".parseHTML").each(function(){
var html = $.parseHTML($(this).text());
$(this).empty();
$(".parseHTML").append(html);
})
}


有特殊標籤的加上 parseHTML 這個class

就行了

2015年4月9日 星期四

自訂事件送到 iframe 裡面

因為 iframe 是為一個新的document 所以需要一些方法把事件送進去

index.html

$(document).contents().trigger( "scan_mode_event", [currentMode] );


ifame.html


parent.$(parent.document).bind( "scan_mode_event", function(event, currentMode){
if(currentMode==2){
$("#ppoe_option").show();
}else{
$("#ppoe_option").hide();
}
})

2014年10月21日 星期二

jquery 顯示繼承效果


var Super = {
a: function() {
console.log("old")
},
b:function(){
console.log("show a");
}
};

var Superb = {
a: function() {
console.log("new");

}
};

var Sub = $.extend(Super, Superb);
Sub.a();
Sub.b();

2014年5月8日 星期四

RegEx 網站

如題:

http://regexlib.com/DisplayPatterns.aspx?cattabindex=1&categoryId=2

真好, 很多驗證就用這就好啦啦~~YA~~