开发者

Date before the current date should not be selected

开发者 https://www.devze.com 2023-02-24 19:42 出处:网络
I am trying to sho开发者_如何学Gow a popup message when any date before current day is clicked in the calendar? This is the function that has the date the user has clicked. setCalendarControlDate(year

I am trying to sho开发者_如何学Gow a popup message when any date before current day is clicked in the calendar? This is the function that has the date the user has clicked. setCalendarControlDate(year, month, day) has the date what user has selected. How can i compare the dates and show the error.

function setCalendarControlDate(year, month, day) {

calendarControl.setDate(year, month, day);
var arguments = "changeDataGrid;day=" + day;
arguments += ";month=" + month;
arguments += ";year=" + year;
//  arguments += ";rowId=" + rowId;
arguments += ";" + rowId;
arguments += ";";

document.getElementById(targetControlId.id).value = arguments;
document.forms[0].submit();

}


var selectedDate = new Date(year, month-1, day);

var valid = selectedDate >= new Date();


// If today was 12th April 2011
year = 2011;
month = 4;
day = 13;

var selectedDate = new Date(year, month-1, day);

var valid = selectedDate >= new Date();

valid ; //# => true

year = 2011;
month = 4;
day = 11;

selectedDate = new Date(year, month-1, day);

var valid = selectedDate >= new Date();

valid ; //# => false
0

精彩评论

暂无评论...
验证码 换一张
取 消