Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 03, 2012 02:22 PM by asteranup
Participant
1126 Points
1299 Posts
Dec 02, 2012 03:32 PM|LINK
Hello,
I want End Date to be less than 15 months from the start date.
How can I do this using Jquery ?
TIA
All-Star
86555 Points
9624 Posts
Moderator
MVP
Dec 03, 2012 09:19 AM|LINK
Something like this should work. I assume startDateField is the start date datepicker textbox and endDateField is the one to change:
$("#startDateField").bind("blur", function() { var endDate = new Date($(this).val()); var newEndDate = new Date(endDate.getFullYear(), endDate.getMonth() + 15, endDate.getDate()); endDate.setDate(newEndDate); $("#endDateField").val( (endDate.getMonth() + 15)+ "/" + endDate.getDate() + "/" + endDate.getFullYear() ); });
30184 Points
4906 Posts
Dec 03, 2012 02:22 PM|LINK
Hi,
Try this-
Start date <input id="start" />dd/MM/yyyy<br /> End date <input id="end" /><br />
$("#start").blur(function(){ var c= $(this).val().split("/") if(c.length==3) { var date=new Date(c[2], c[1],c[0]); date.setMonth(date.getMonth()); $("#end").val(date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear()); } });
ramll
Participant
1126 Points
1299 Posts
Jquery End Date Based on Start Date
Dec 02, 2012 03:32 PM|LINK
Hello,
I want End Date to be less than 15 months from the start date.
How can I do this using Jquery ?
TIA
DarrellNorto...
All-Star
86555 Points
9624 Posts
Moderator
MVP
Re: Jquery End Date Based on Start Date
Dec 03, 2012 09:19 AM|LINK
Something like this should work. I assume startDateField is the start date datepicker textbox and endDateField is the one to change:
$("#startDateField").bind("blur", function() { var endDate = new Date($(this).val()); var newEndDate = new Date(endDate.getFullYear(), endDate.getMonth() + 15, endDate.getDate()); endDate.setDate(newEndDate); $("#endDateField").val( (endDate.getMonth() + 15)+ "/" + endDate.getDate() + "/" + endDate.getFullYear() ); });Darrell Norton's Blog
Please click "Mark as Answer" if this helped you.
asteranup
All-Star
30184 Points
4906 Posts
Re: Jquery End Date Based on Start Date
Dec 03, 2012 02:22 PM|LINK
Hi,
Try this-
$("#start").blur(function(){ var c= $(this).val().split("/") if(c.length==3) { var date=new Date(c[2], c[1],c[0]); date.setMonth(date.getMonth()); $("#end").val(date.getDate()+"/"+date.getMonth()+"/"+date.getFullYear()); } });Anup Das Gupta
Mark as Answer if you feel so. Visit My Blog