View Full Version : Validate Date

07-29-2006, 11:32 AM
I want to validate 5 dates in a form using javascript. How can I do that ? Also I want to validate the Gender. Means the person has to select either male or female.

Below is the link of the form.




Philip M
07-29-2006, 12:00 PM
Not sure what you mean by "validate" as you are using select boxes. (By the way, 2005 is the last year available). Are you wishing to check that "departure date" is after "arrival date" or something?

Validate gender (one or other radio button must be selected):-

if (!document.business_form.sex[0].checked && !document.business_form.sex[1].checked)
alert ( "Please Select Gender Male or Female" );
return false;

07-30-2006, 06:43 AM
The generic way to validate a group of any number of radio buttons:

function hasRadioChecked(radGroup){
var len = radGroup.length;
for (var i=0; i<len; i++){
if (radGroup[i].checked){
return true;
return false;

//to use
function validate(frm){
if (!hasRadioChecked(frm.gender)){
alert("You must select one.");
return false;
return true;