How can i validate a date input by the user to make sure that the date entered is within the accepted limit (e.g. date does not exceed 29 for feb, 30 for apr, jun, and nov and 31 for jan, mar, may, jul, aug, oct and dec) and the months not exceeding 12?
I have tried to add in conditions and the && simply does not work for me as it always returns an error.
My javascript function is as below:
function parseDate(s)
{
var dP = s.split("/");
var date = new Date(dP[2], (dP[1] - 1), dP[0]);
var dateStrParts = date.toString().split(" ");
return (date.getDate() + ", " + dateStrParts[1] + " " + dateStrParts[3]);
}
I have an onchange currently that will convert the month number to month name from user input and i believe i need to add another function for validation.
Hence how could i write the validation function and how should i add it into my onchange event?
There is no submit button for the date.
Thanks!