Validate the Date in Javascript

 //validation of From Date//Here FromDay,FromMonth,FromYear & ToDay,ToMonth,_ToYear are the names ofthe form fields corresponding to from date and to _dates. Assuming thatthese are drop down fields on the form.function validateFromDate(){	var dt =document.formName.FromDay.options_[formName.FromDay.selectedIndex].value;	var mon =document.formName.FromMonth.options_[formName.FromMonth.selectedIndex].value - 1;	var yr =document.formName.FromYear.options_[formName.FromYear.selectedIndex].value;//Now construct a Javascript date object	var now = new Date(yr,mon,dt);	fromTime = now.getTime();	if(!(now.getDate() == dt && now.getMonth() _== mon && now.getFullYear() ==yr))	{		alert("Invalid From Date!!!");		return false;	}	else	{		isFromDate = true;		return true;	}}
Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

Recent Articles: