Hi,
I was working in Tigra Calendar which is a really good javascript calendar library. I was stucked when there was a need to disable dates after the current date. Here is how i was able to solve the problem.
Step 1: Edit tcal.css and add the following lines
div#tcal td.disabled_days {
font-style: italic;
color: silver;
cursor: auto;
}
Step 2: Edit tcal.js and go to the function f_tcalGetHTML (d_date)
After the lines :
if (d_current.getMonth() != d_date.getMonth())
a_class[a_class.length] = s_pfx + 'OtherMonth';
if (d_current.getDay() == 0 || d_current.getDay() == 6)
a_class[a_class.length] = s_pfx + 'Weekend';
if (d_current.valueOf() == d_today.valueOf())
a_class[a_class.length] = s_pfx + 'Today';
if (d_current.valueOf() == d_selected.valueOf())
a_class[a_class.length] = s_pfx + 'Selected';
And Before the line
d_current.setDate(++n_date)
Add these lines
//start of ritesh's code
var today = new Date();
var dd = today.getDate();
var mm = today.getMonth() + 1; //January is 0!
var yyyy = today.getFullYear();
if (dd < 10) { dd = '0' + dd } if (mm < 10) { mm = '0' + mm } today = mm + '/' + dd + '/' + yyyy;
today=new Date(today);
var dd1 = d_current.getDate();
var mm1 = d_current.getMonth() + 1; //January is 0!
var yyyy1 = d_current.getFullYear();
if (dd1 < 10) { dd1 = '0' + dd1 } if (mm1 < 10) { mm1 = '0' + mm1 } d_current_1 = mm1 + '/' + dd1 + '/' + yyyy1;
d_current_1=new Date(d_current_1);
//Check if the date of calendar is less than today's date
if (d_current_1 <= today) {
//default code
s_html += '<td' + f_tcalRelDate(d_current) + (a_class.length ? ' class="' + a_class.join(' ') + '">' : '>') + n_date + '</td>';
}
else {
s_html += '<td class="disabled_days">' + n_date + '</td>'
}
And That's It!! Check the calendar the dates after the current dates would be disabled .
Thanks
Ritesh Tandon
Blog is about ASP.NET, Web Services, Programming Language problems which are faced by a developer in routine work. Motive is to solve all the major problems related to the daily development work. Blog features latest technologies and solutions to the most typical problems. Contact me on LinkedIn https://www.linkedin.com/in/riteshtandon23/
Amazon Ad
How to implement Captcha v3 in ASP.NET
I was facing an issue of dom parsing in my website. I finally resolved it by using Google Captcha V3. Step 1: Get your keys from https:...
-
Hi Guys, I was facing a strange problem while sending data from jquery $.ajax to ASP.NET MVC Web API. I had earlier made lot of web appli...
-
Hi Guys, I was able to successfully create a responsive and very fast website with EF6 and ASP.NET 4.5. Here is how i was able to do it s...
7 comments:
thank you so much dude its awesome
Glad it helped!!
That's very helpful...thank you very much..!!
how to disable date 3 days from this day..
thank you so much!
Glad it helped.
Thank you
Post a Comment
Comments are welcome, Please join me on my Linked In account
http://in.linkedin.com/pub/ritesh-tandon/21/644/33b