If you need a quick jQuery & jQuery UI datePicker script that will restrict the range of the selects, then you've come to the right psot.
Today's script is a widget that has 2 datePicker choices "check in" and "check out".
The date selector for the #checkout needs to be setup so a #checkout date cannot start before the #checkin date and viceversa.
Here is the snippet to setup the jQuery UI datepicker object for both the #checkin and #checkout.
Note that in order for the date picker to open on both the image and input box you need the attribute "showOn" set to "both", other options and documentation can be found at the jQuery UI site.
The attribute "beforeShow" is an event handler that will call the customDateFunction before the datepicker is shown to the user.
$(document).ready(function(){
$("#checkin,#checkout").datepicker({
showOn: "both",
buttonImage: 'assets/javascript/jquery/calendar.png',
buttonImageOnly: true,
beforeShow: customDateFunction,
dateFormat: "mm/dd/yy",
firstDay: 1,
changeFirstDay: false
});
});
The "beforeShow" event passes a reference to the object that its being called on i.e. the input box in this case. We will use this to check which input box it is.
To make sure the #checkout date cannot start before the #checkin date we need to make sure the #checkout is not empty then set & return the attribute maxDate to the jQuery UI datePicker. The maxDate will disable any future dates so the user will only be able to select a start date up to the maxDate.
/*
use the dateMin and dateMax attributes to enable
the date selection to not end before the start date and
not start before the end date
*/
function customDateFunction(input)
{
//if the button called is checkin
//set the maxDate to the checkout date
if (input.id == "checkin")
{
if ($("#checkout").datepicker("getDate") != null)
dateMax = $("#checkout").datepicker("getDate");
return {maxDate: dateMax};
}
else if (input.id == "checkout")
{
if ($("#checkin").datepicker("getDate") != null)
dateMin = $("#checkin").datepicker("getDate");
return { minDate: dateMin };
}
}
25 comments:
Thanks , This code helps me to solve an issue
It seems you are so busy in last month. The detail you shared about your work and it is really impressive that's why i am waiting for your post because i get the new ideas over here and you really write so well.
Selenium training in Chennai
Selenium training in Bangalore
Selenium training in Pune
Selenium Online training
Selenium training in bangalore
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
Python training in bangalore
Python course in pune
Python training in bangalore
Hi buddy, your post is very interesting and is very relevant to my desires. I am bookmarking your website to come back and read later.
DevOps Training in Chennai
Angular 6 Training in Chennai
Automation Anywhere Training in Chennai
Selenium Training In Marathahalli
UI Development Training In Marathahalli
Best blog to read and develop skills. Thanks for sharing this blog.thanks for your information really good and very nice web design company in velachery
I have read your blog and I got very useful and knowledgeable information from your blog. It’s really a very nice article. DevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
i really appreciate your work. thank you so much useful every line content it very understand.
Python Training in Chennai
Python Training in Training
Python Training in Bangalore
Python Hyderabad
Python Training in Coimbatore
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this. Thank you for excellent article.You made an article that is interesting.
DevOps Training in Chennai
DevOps Online Training in Chennai
Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
DevOps Training in Bangalore
DevOps Training in Hyderabad
DevOps Training in Coimbatore
DevOps Training
DevOps Online Training
I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post.
hardware and networking training in chennai
hardware and networking training in tambaram
xamarin training in chennai
xamarin training in tambaram
ios training in chennai
ios training in tambaram
iot training in chennai
iot training in tambaram
9, found that Java lost popularity in September, with an estimated 17.9 percent of developers using it as opposed to 18.8 percent in the previous month's index. Java still finished as the top language, but if the downward trend continues, the C language, ranked second with 17.7 percent of users, will be No.
Java Training in Chennai
Java Training in Bangalore
Java Training in Hyderabad
Java Training in Coimbatore
Java Training
Best blog to read and develop skills. Thanks for sharing this blog.thanks for your information really good and very nice..
java training in chennai
java training in omr
aws training in chennai
aws training in omr
python training in chennai
python training in omr
selenium training in chennai
selenium training in omr
well
Software Testing Training in Chennai | Certification | Online
Courses
Software Testing Training in Chennai
Software Testing Online Training in Chennai
Software Testing Courses in Chennai
Software Testing Training in Bangalore
Software Testing Training in Hyderabad
Software Testing Training in Coimbatore
Software Testing Training
Software Testing Online Training
Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…
AWS Course in Chennai
AWS Course in Bangalore
AWS Course in Hyderabad
AWS Course in Coimbatore
AWS Course
AWS Certification Course
AWS Certification Training
AWS Online Training
AWS Training
Nice tutorial. Thanks for sharing the valuable information. it’s really helpful. Who want to learn this blog most helpful. Keep sharing on updated tutorials…acte chennai
acte complaints
acte reviews
acte trainer complaints
acte trainer reviews
acte velachery reviews complaints
acte tambaram reviews complaints
acte anna nagar reviews complaints
acte porur reviews complaints
acte omr reviews complaints
Thank you for the information. It is very useful and informative
angular js course in chennai
angular course in chennai
angular js online course in chennai
angular js course in bangalore
angular js course in hyderabad
angular js course in coimbatore
angular js course
angular js online course
Great Article… I love to read your blog because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your blog because, they become more and more interesting from the starting line to till the end.
https://www.acte.in/oracle-training-in-chennai
https://www.acte.in/oracle-training-in-bangalore
https://www.acte.in/oracle-training-in-hyderabad
https://www.acte.in/oracle-certification-training
https://www.acte.in/hadoop-training-in-chennai
https://www.acte.in/big-data-and-hadoop-training-in-bangalore
Really very informative post you shared here. Kindly keep blogging. I want people to know just how good this information is in your article. It’s interesting content and Great work. nice to read.
oracle training in bangalore
oracle training in hyderabad
oracle training
oracle online training
hadoop training in chennai
hadoop training in bangalore
Hey! Great work. I feel so happy to be here reading your post.
Cyber Security Training Course in Chennai | Certification | Cyber Security Online Training Course | Ethical Hacking Training Course in Chennai | Certification | Ethical Hacking Online Training Course |
CCNA Training Course in Chennai | Certification | CCNA Online Training Course | RPA Robotic Process Automation Training Course in Chennai | Certification | RPA Training Course Chennai | SEO Training in Chennai | Certification | SEO Online Training Course
Great Article… I love to read your blog because your writing style is too good, its is very very helpful for all of us and I never get bored while reading your blog because,
amazon web services aws training in chennai
microsoft azure training in chennai
workday training in chennai
android-training-in chennai
ios training in chennai
Aivivu đại lý vé máy bay, tham khảo
vé máy bay đi Mỹ tháng nào rẻ nhất
giá vé máy bay đi từ mỹ về việt nam
mua vé máy bay từ đức về việt nam
lịch bay từ moscow đến hà nội
chuyến bay từ anh về việt nam
lịch bay từ pháp về việt nam
giá khách sạn cách ly
Wow what a first rate records just greater or less global Day its intensely exceptional informative assertion. thank you for the kingdom... Facebook Hacking Software Free Download Full Version For Pc
that is a nice hard article.i am stunning a lot appreciative taking into account your best take steps.You positioned absolutely very malleable sponsorship. hold it occurring. hold running a blog. seeking to reading your neighboring book..... MS Office 2016 Product Key Crack
Excellent site work its precious.
Movavi Video editor Crack
Speedify Crack
Recuva Crack
Exiftool Crack
Post a Comment