1. Jquery UI DatePicker 주말 선택 안하기 :

$(function() {

$('#datepicker').datepicker({ 

dateFormat: "yy-mm-dd",

regional: "ko",

beforeShowDay: function(date){

var day = date.getDay();

return [(day != 0 && day != 6)];

}

});


});





2. 특정요일만 선택하기 :


0 : 일요일

6 : 토요일



//아래 코드는 매주 화요일과 금요일만 선택가능


$(function() {

$('#datepicker').datepicker({ 

dateFormat: "yy-mm-dd",

regional: "ko",

beforeShowDay: function(date){

var day = date.getDay();

return [(day != 0 && day != 1 && day != 3 && day != 4 && day != 6)];

}

});

});




3. 특정일만 선택하기


$(function() {


//선택가능 날짜 

var availableDates = ["2015-01-01", "2015-01-13"];

function available(date) {

var thismonth = date.getMonth()+1;

var thisday = date.getDate();

if(thismonth<10){

thismonth = "0"+thismonth;

}

if(thisday<10){

thisday = "0"+thisday;

}

    ymd = date.getFullYear() + "-" + thismonth + "-" + thisday;


    if ($.inArray(ymd, availableDates) >= 0) {

        return [true,"",""];

    } else {

        return [false,"",""];

    }

}

$('#datepicker').datepicker({ 

dateFormat: "yy-mm-dd",

regional: "ko",

beforeShowDay: available 

});


});



출처: http://ellordnet.tistory.com/12 [IT in MT]

'자바스크립트' 카테고리의 다른 글

모달 tinggle.js  (0) 2018.01.25
jquery - select option 선택값 가져오기  (0) 2018.01.22
구글 선형 챠트  (0) 2018.01.06
구글지도 내위치  (0) 2017.12.31
jquery get 한글 깨짐  (0) 2017.12.30

+ Recent posts