MySQL Forums
Forum List  »  PHP

Re: issue getting dates on form + adding to database
Posted by: Peter Brawley
Date: November 18, 2016 12:26PM

Whatever date format you're using in the form. it needs to validate the user's input. That's often most easily done in Javascript, eg ...

function isDate (year, month, day) {
  if (! (isYear(year, false) && isMonth(month, false) && isDay(day, false))) return false;
  var intYear = parseInt(year);
  var intMonth = parseInt(month);
  var intDay = parseInt(day);
  if (intDay > daysInMonth[intMonth]) return false; 
  if ((intMonth == 2) && (intDay > daysInFebruary(intYear))) return false;
  return true;
}

Options: ReplyQuote


Subject
Written By
Posted
Re: issue getting dates on form + adding to database
November 18, 2016 12:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.