function register_onsubmit(theForm) 
{

retval = isValidDate(theForm.cboMonth.options[theForm.cboMonth.selectedIndex].value,theForm.cboDay.options[theForm.cboDay.selectedIndex].value,theForm.cboyearofbirth.options[theForm.cboyearofbirth.selectedIndex].value);
  
  	if(retval == false)
		{
			return(false);
		}
		//else
		//{
		//	alert("It is a Valid Date");
		//}
}

/* ======================================================================
FUNCTION:	IsNull
 
INPUT:		val - the value to be tested

RETURN:  	true, if the value is null;
      		false, otherwise.

PLATFORMS:	Netscape Navigator 3.01 and higher,
		Microsoft Internet Explorer 3.02 and higher,
		Netscape Enterprise Server 3.0,
		Microsoft IIS/ASP 3.0.
====================================================================== */
function IsNull( val ) {
	var isValid = false;

 	if (val+"" == "null")
 		isValid = true;
		
	return isValid;
}  // end IsNull
/* ======================================================================
FUNCTION:	IsUndef
 
INPUT:		val - the value to be tested

RETURN:  	true, if the value is undefined
      		false, otherwise.

PLATFORMS:	Netscape Navigator 3.01 and higher,
		Microsoft Internet Explorer 3.02 and higher,
		Netscape Enterprise Server 3.0,
		Microsoft IIS/ASP 3.0.
====================================================================== */
function IsUndef( val ) {
	var isValid = false;

 	if (val+"" == "undefined")
 		isValid = true;
		
	return isValid;
}  // end IsUndef



/* ======================================================================
FUNCTION:	IsBlank
 
INPUT:		val - the value to be tested

RETURN:  	true, if the string is null, undefined or an empty string, ""
      		false, otherwise.

CALLS:		IsNull(), IsUndef() which are defined elsewhere in the Script Library

PLATFORMS:	Netscape Navigator 3.01 and higher,
		Microsoft Internet Explorer 3.02 and higher,
		Netscape Enterprise Server 3.0,
		Microsoft IIS/ASP 3.0.
====================================================================== */
function IsBlank( str ) {
	var isValid = false;

 	if ( IsNull(str) || IsUndef(str) || (str+"" == "") )
 		isValid = true;
		
	return isValid;
}  // end IsBlank



/* ======================================================================
FUNCTION:  	IsAlpha

INPUT:		str (string) - the string to be tested

RETURN:  	true, if the string contains only alphabetic characters 
		false, otherwise.

PLATFORMS:	Netscape Navigator 3.01 and higher,
		Microsoft Internet Explorer 3.02 and higher,
		Netscape Enterprise Server 3.0,
		Microsoft IIS/ASP 3.0.
====================================================================== */
function IsAlpha(str) {
	// Return immediately if an invalid value was passed in

	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";	// convert to a string for performing string comparisons.

	// Loop through string one character at time,  breaking out of for
	// loop when an non Alpha character is found.
  	for (i = 0; i < str.length; i++) {
		// Alpha must be between "A"-"Z", or "a"-"z"
		if ( !( ((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ) ) {
         				isValid = false;
         				break;
      			}
   } // end for loop
   
	return isValid;
}  // end IsAlpha 

/* ======================================================================
FUNCTION:	IsAlphaNum

INPUT:		str (string) - a string that will be tested to ensure that
      		each character is a digit or a letter.

RETURN:  	true, if all characters in the string are a character from 0-9	  						or a-z or A-Z;  
		false, otherwise

PLATFORMS:	Netscape Navigator 3.01 and higher,
	  	Microsoft Internet Explorer 3.02 and higher,
	  	Netscape Enterprise Server 3.0,
	  	Microsoft IIS/ASP 3.0.
====================================================================== */
function IsAlphaNum( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;
	
	// convert to a string for performing string comparisons.
   	str += "";	

	// Loop through length of string and test for any alpha numeric 
	// characters
   	for (i = 0; i < str.length; i++)
   	{
			// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
      	if (!(((str.charAt(i) >= "0") && (str.charAt(i) <= "9")) || 
      			((str.charAt(i) >= "a") && (str.charAt(i) <= "z")) ||
      			((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")) ||
      			((str.charAt(i) == "_"))))
			{
				isValid = false;
				break;
			}	
   	} // END for   
   
   	return isValid;
}  // end IsAlphaNum

/* ======================================================================
FUNCTION:  	IsValidEmail
 
INPUT:    	str (string) - an e-mail address to be tested

RETURN:  	true, if the string contains a valid e-mail address which is a string
		plus an '@' character followed by another string containing at least 
		one '.' and ending in an alpha (non-punctuation) character.
		false, otherwise

CALLS:		IsBlank(), IsAlpha() which are defined elsewhere in the Script Library

PLATFORMS:	Netscape Navigator 3.01 and higher,
		Microsoft Internet Explorer 3.02 and higher,
	  	Netscape Enterprise Server 3.0,
	  	Microsoft IIS/ASP 3.0.
====================================================================== */
function IsValidEmail( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")	
		return false;

	var isValid = true;

	str += "";

	namestr = str.substring(0, str.indexOf("@"));  // everything before the '@'
	domainstr = str.substring(str.indexOf("@")+1, str.length); // everything after the '@'

	// Rules: namestr cannot be empty, or that would indicate no characters before the '@',
	// domainstr must contain a period that is not the first character (i.e. right after
	// the '@').  The last character must be an alpha.
   	if (IsBlank(str) || (namestr.length == 0) || 
			(domainstr.indexOf(".") <= 0) ||
			(domainstr.indexOf("@") != -1) ||
			!IsAlpha(str.charAt(str.length-1)))
		isValid = false;
   
   	return isValid;
} // end IsValidEmail

//  ***********  VALIDATION   FOR   FIRST  AND   LAST   NAME      *********  //
 function validateufname()
    {
           var     infname=document.forms[1].fname.value       
                 if(!IsBlank(infname))
                        {       
      
                          validfname=IsAlpha(infname)
    	                     if(!validfname)
                            {
                           alert("First Name field must contain Alphabets only")
	                        document.forms[1].fname.focus()
   	                     return false    // validfname
		                      }
                              return  true
                        }                
                             
                  alert("First Name field cannot be left blank")
                 document.forms[1].fname.focus()
   	            return false
   
}

//   ********************************
//   ********************************

 function validateulname()
    {
           var     inlname=document.forms[1].lname.value       
                 if(!IsBlank(inlname))
                        {       
      
                          validfname=IsAlpha(inlname)
    	                     if(!validfname)
                            {
                           alert("Last Name field must contain Alphabets only")
	                        document.forms[1].lname.focus()
   	                     return false    // validfname
		                      }
                              return  true
                        }                
                             
                  alert("Last Name field cannot be left blank")
                 document.forms[1].lname.focus()
   	            return false
   
}
//   *********************************************************************** //






function validate(fieldName,fieldValue)
 {
         if(IsBlank(fieldValue))
              {
                  alert(fieldName+" cannot be left blank.")
					return false
				}
					return true
}
//   ********************************


//    ********* VALIDATION    FOR     EMAIL      FIELD      *************//    
 function validateuemail()
    {
           var     inemail=document.forms[1].email.value       
                 if(!IsBlank(inemail))
                        {       
      
                          validemail=IsValidEmail(inemail)
    	                     if(!validemail)
                            {
                           alert("Email Address you entered is invalid ")
	                        document.forms[1].email.focus()
   	                     return false    // validfname
		                      }
                              return  true
                        }                
                             
                  alert("Email field cannot be left blank")
                 document.forms[1].email.focus()
   	            return false
   
}

//   *****************************************8
//  ***********  VALIDATION   FOR    USERNAME      *********  //

 function validateusername()
    {
           var     inuser=document.forms[1].login.value       
                 if(!IsBlank(inuser))
                        {       
      
                          validuser=IsAlphaNum(inuser)
    	                     if(!validuser)
                            {
                           alert("Login ID must contain Alphabets and numeric only")
	                        document.forms[1].login.focus()
   	                     return false    // validfname
		                      }
                              return  true
                        }                
                             
                  alert("Login ID field cannot be left blank")
                 document.forms[1].login.focus()
   	            return false
   
}

//   ********************************
//  ***********  VALIDATION   FOR    PASSWORD      *********  //

 //   ***********************************

function validatepwd()
    {
           var     inpwd=document.forms[1].pwd.value 
           var  len=document.forms[1].pwd.value.length      
                 if(!IsBlank(inpwd))
                        {       
						if((len>=4)&& (len<=12))
								{       
                                validpwd=IsAlphaNum(inpwd)
    							if(!validpwd)
								{
									alert("Password Field must contain Alphabets and numeric only")
									document.forms[1].pwd.focus()
   									return false    // validfname
								}
								return  true
								}   
								else
								{ 
                      alert("Password field must be 4-12 characters")
                      document.forms[1].pwd.focus()
   	                return false
                       }
             
         }
         {                               
                             
                  alert("Password Field cannot be left blank")
                 document.forms[1].pwd.focus()
   	            return false
   
}
}

//   ********************************
//  ***********  VALIDATION   FOR    PASSWORD CONFIRMATION      *********  //

 function validatepass()
    {
           var     inpass=document.forms[1].pwd.value       
           var    incpass=document.forms[1].cpwd.value
                 if(!IsBlank(incpass))
				      {       
							if (inpass!=incpass)
							{
							alert("Password mismatch")
							document.forms[1].cpwd.focus()
							return false
							}
							return true
							validcpass=IsAlphaNum(incpass)
    	                     if(!validcpass)
								{
								alert("Confirm Password Field must contain Alphabets and numeric only")
								document.forms[1].cpwd.focus()
   								return false
								}
								return  true
								}                
                             
					alert("Confirm Password Field cannot be left blank")
					document.forms[1].cpwd.focus()
   					return false
					}

//   ********************************

//  ***********  VALIDATION   FOR    tel    *********  //

 function validatetel()
    {
           var     intel=document.forms[1].tel.value       
                  if(IsBlank(intel))
					{       
					 alert("Phone field cannot be left blank")
					 document.forms[1].tel.focus()
					 return false
   					}
   					return true
   					
   					
   	}

//   ********************************

//  ***********  VALIDATION   FOR    Address   *********  //

 function validateadd()
    {
           var     inadd=document.forms[1].add.value       
                  if(IsBlank(inadd))
					{       
					 alert("Address field cannot be left blank")
					 document.forms[1].add.focus()
					 return false
   					}
   					return true 					
   	}

//   ********************************
//  ***********  VALIDATION   FOR    CITY     *********  //

 function validatecity()
    {
           var     incity=document.forms[1].city.value       
                 if(IsBlank(incity))
					{       
					alert("City field cannot be left blank")
					document.forms[1].city.focus()
   					return false
					}
					return  true
	}                
   
//   ********************************
//  ***********  VALIDATION   FOR    STATE    *********  //

 function validatestate()
    {
           var     instate=document.forms[1].state.value       
                 if(IsBlank(instate))
                        {       
						alert("State field cannot be left blank")
						document.forms[1].state.focus()
   						return false
   						}
                         return  true
     }                
                             
     
//   ********************************
//  ***********  VALIDATION   FOR    COUNTRY    *********  //

 function validatecountry()
    {
           var     incountry=document.forms[1].country.value       
                 if(IsBlank(incountry))
                        {       
						alert("Country field cannot be left blank")
						document.forms[1].country.focus()
   						return false
						}                
                        return  true
                  
   
}

//   ********************************

//   *****************************************8


function check(form) 
{
//alert(form.FromMonth.options[form.FromMonth.selectedIndex].value)
//alert(form.FromDay.options[form.FromDay.selectedIndex].value)
//alert(form.FromYear.options[form.FromYear.selectedIndex].value)
retval = isValidDate(form.FromMonth.options[form.FromMonth.selectedIndex].value,form.FromDay.options[form.FromDay.selectedIndex].value,form.FromYear.options[form.FromYear.selectedIndex].value);
//alert(retval)
  
  	if(retval == false)
		{
			return(false);
		}
		else
		{
		return(true);
		}
}

//-->
function checkTodate(form) 
{
//alert(form.FromMonth.options[form.FromMonth.selectedIndex].value)
//alert(form.FromDay.options[form.FromDay.selectedIndex].value)
//alert(form.FromYear.options[form.FromYear.selectedIndex].value)
retoval = isValidDate(form.ToMonth.options[form.ToMonth.selectedIndex].value,form.ToDay.options[form.ToDay.selectedIndex].value,form.ToYear.options[form.ToYear.selectedIndex].value);
//alert(retval)
  
  	if(retoval == false)
		{
			return(false);
		}
		else
		{
		return(true);
		}
}

//-->

//Date Validate Function. Return False if the date is invalid
//Usage : isValidDate(Month,Day,Year)
	
	function isValidDate(varMonth,varDay,varYear)
	{
		var arrmonthNo = new Array(13);
		var arrmonthChar = new Array(13);
		arrmonthChar[1] = '1';
		arrmonthChar[2] = '2';
		arrmonthChar[3] = '3';
		arrmonthChar[4] = '4';
		arrmonthChar[5] = '5';
		arrmonthChar[6] = '6';
		arrmonthChar[7] = '7';
		arrmonthChar[8] = '8';
		arrmonthChar[9] = '9';
		arrmonthChar[10] = '10';
		arrmonthChar[11] = '11';
		arrmonthChar[12] = '12';

			for (i = 1; i <= 12; i++)
			    {
						arrmonthNo[i] = i;
			    }

			for (i = 1; i <= 12; i++)
			    {
						if(varMonth == arrmonthChar[i])
						{
							month = arrmonthNo[i];
							month = parseInt(month);
						}
			    }
			if ((month==4 || month==6 || month==9 || month==11) && parseInt(varDay) == 31)
			{
				alert("Month "+arrmonthChar[month]+" has only 30 days!");
				return(false);
			}
		
			if (month == 2)
			{ 
				var year = parseInt(varYear);
				var day = parseInt(varDay);
				var yearfloat = (year / 4);
				var yearint = parseInt(yearfloat);
				var yearCheck = (yearint * 4)
					if(year == yearCheck)
					{
						Check4 = true;
					}
					else
					{
						Check4 = false;
					}

				yearfloat = (year / 100);
				yearint = parseInt(yearfloat);
				yearCheck = (yearint * 100)
					if(year == yearCheck)
					{
						Check100 = true;
					}
					else
					{
						Check100 = false;
					}
	
				yearfloat = (year / 400);
				yearint = parseInt(yearfloat);
				yearCheck = (yearint * 400)
					if(year == yearCheck)
					{
						Check400 = true;
					}
					else
					{
						Check400 = false;
					}
	
				var CheckLeapYear = ((Check4 == true) 

&& (Check100 != true) || (Check400 == true))
			
					if(CheckLeapYear == true)
					{
						if(day > 29)
						{
							alert("February in "+ year +" has only 29 days!");						
							return(false);
						}
					}
					
					if(CheckLeapYear == false)
					{
						if(day > 28)
						{
							alert("February in "+ year +" has only 28 days!");						
							return(false);
						}
					}	
			 }
		}



function validateForm() 
{
 if(!validateusername())
  return false
if(!validatepwd())
  return false
if(!validatepass())
  return false
 if(!validateuemail())
return  false
if(!validateufname())
  return false
if(!validateulname())
  return false
if(!validatetel())
 return false
 if(!validateadd())
 return false
 if(!validatecity())
 return false
 if(!validatestate())
 return false
 if(!validatecountry())
 return false
  
  }
// Created with XBuilder (3.0.6205.1), Copyright (c) 1997-2001 XCache Technologies, Inc. All Rights Reserved 
// Page: http://gaurav/includes/validate.js 
// Date: 06/11/02 09:37 AM 

