Jump to content

date validation


The Little Guy

Recommended Posts

Here is what I came up with, but I don't know if it is good or not:

 

function validDate(y, m, d){
y = parseInt(y);
m = parseInt(m);
d = parseInt(d);
ld = new Date(y, m, 0);
lastDate = ld.getDate();
date = new Date(y, m, d);
if(y != date.getFullYear())
	return false;
if(m != date.getMonth())
	return false;
if(d != date.getDate() || date.getDate() > lastDate)
	return false;
return true;
}

Link to comment
https://forums.phpfreaks.com/topic/263562-date-validation/#findComment-1350848
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.