javascript - Get the last Valid Value of day in a date using JQuery -


i have code :

//set delivery date based request date document.getelementbyid('ctl00_ctl00_pagecontent_content_scs_requestdate').onblur = function (e) {  var requestdate = new date($('#ctl00_ctl00_pagecontent_content_scs_requestdate').val()); var dd = requestdate.getdate()+1; var mm = requestdate.getmonth()+1; //january 0!  var yyyy = requestdate.getfullyear(); if(dd<10){dd='0'+dd}  if(mm<10){mm='0'+mm}  requestdate = yyyy+'-'+mm+'-'+dd;     $('#ctl00_ctl00_pagecontent_content_scs_deliverydate').val(requestdate); 

it works fine if requestdate day + 1 on range of given month, if requestdate day last day of given month , add 1 day, deliverydate field display mm/dd/yy mean date set field invalid.

how can check if requestdate day last day of month , set delivery date right value.

you can add a date date instead of adding day of month value, can read values desired date.

var requestdate = new date($('#ctl00_ctl00_pagecontent_content_scs_requestdate').val()); requestdate.setdate(requestdate.getdate() + 1); var dd = requestdate.getdate(); var mm = requestdate.getmonth() + 1; //january 0!  var yyyy = requestdate.getfullyear();  if (dd < 10) {     dd = '0' + dd } if (mm < 10) {     mm = '0' + mm } requestdate = yyyy + '-' + mm + '-' + dd; 

Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -