Hey guys,

I was wondering if there is possibly an "onBlurr" or "onChange" way I can check using JavaScript if a Birth date is correct I've seen a couple but I have a pretty simplistic way about how I want to get it done.

Basically what I would like to do is check the months and check if they've entered an incorrect date for them (I will be using the 3 drop down boxes method).

so if a users selects 30-31 for feb i want it to check the minute its changed for either one in order to notify the user that its an invalid birth date, which would apply for all months totalling 30 days.

also the same for the leap year of feb if its 29 but the year is not divisible by 4 then the date is still invalid (I have a rough sketch idea of how to validate this however it would be very handy if i could do it onblurr like i said).

Thanks in advance

onChange onBlur are for javascript. there can be made a date check without any problems

which one of the two is faster/More reliable?
atm im doing it in javascript

Its depending what will be the inputs which(select boxes or text input) you will use and when you will make the check while selecting date, or when submitting your form

Ok so this is the code I have a.t.m
However it only works on form submission.
This is the exact code I would like to implement "onChange".

Any help would be GREAT thanks again :)

function check(theForm)
{
   //=======================================================================
   //			Variables to check correct issuement later
   //=======================================================================

   var checker;
   //  Select fields alternate test
   var day = theForm.day.value;
   var month = theForm.month.value;
   var year = theForm.year.value;
   
   var age = document.getElementById('userAge');


   if (month == "February")
   {
	if (day	> 29)
	{
	   var adder = age.innerHTML + ""; // a new variavble is created which is the innerHTML through the changer fields
	   adder = '<label class="incorrect" id="userAge"> *Date Of birth*: </label>'; // changes the current label tag into the innerHTML field
	   age.innerHTML = adder; // changes the innerHTML to equal the adder
	   checker = false; // checker becomes false and needs to show the user
	}
	else if (( day > 28) && ( year%4 != 0 ))
	{
	   var adder = age.innerHTML + ""; // a new variavble is created which is the innerHTML through the changer fields
	   adder = '<label class="incorrect" id="userAge"> *Date Of birth*: </label>'; // changes the current label tag into the innerHTML field
	   age.innerHTML = adder; // changes the innerHTML to equal the adder
	   checker = false; // checker becomes false and needs to show the user
	}
	else
	{
	   var adder = age.innerHTML + ""; // a new variavble is created which is the innerHTML through the changer fields
	   adder = '<label class="loginLabel" id="userAge"> Date Of birth: </label>'; // changes the current label tag into the innerHTML field
	   age.innerHTML = adder; // changes the innerHTML to equal the adder
	}
   }
   else if ( ( month == "April" ) || ( month == "June") || ( month == "September") || ( month == "November") )
   {
	if (day > 30 )
	{
	   var adder = age.innerHTML + ""; // a new variavble is created which is the innerHTML through the changer fields
	   adder = '<label class="incorrect" id="userAge"> *Date Of birth*: </label>'; // changes the current label tag into the innerHTML field
	   age.innerHTML = adder; // changes the innerHTML to equal the adder
	   checker = false; // checker becomes false and needs to show the user
	}
	else
	{
	   var adder = age.innerHTML + ""; // a new variavble is created which is the innerHTML through the changer fields
	   adder = '<label class="loginLabel" id="userAge"> Date Of birth: </label>'; // changes the current label tag into the innerHTML field
	   age.innerHTML = adder; // changes the innerHTML to equal the adder
	}
   }
   // see if the user has false or true contact details... if false
   if (checker == false)
   {
 	alert("You have 1 or more incorrect fields. Please correct them now!"); // let them know that they have inccorect fields
   	return false; // make the onsumbit false
   }

}

I merged this thread with the duplicate one in the PHP board.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.