function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }


function formValidator(theform){

	
	if (theform.startdate.value == "" || theform.startdate.value==null)
	{
		alert ("Please enter the [Activity Start Date]");
		theform.startdate.focus();
    	return (false);
	}
	if (theform.enddate.value == "" || theform.enddate.value==null)
	{
		alert ("Please enter the [Activity End Date]");
		theform.enddate.focus();
    	return (false);
	}



var strDate1;
var strDate2;
var strDay1;
var strMonth1;
var strYear1;
var strDay2;
var strMonth2;
var strYear2;
var venddate;

strDate1 = theform.startdate.value ;
strDate2 = theform.enddate.value ;

strDay1 = strDate1.substr(0, 2);
strMonth1 = strDate1.substr(3, 2);
strYear1 = strDate1.substr(6, 4);
vstartdate = strYear1 + strMonth1 + strDay1;

strDay2 = strDate2.substr(0, 2);
strMonth2 = strDate2.substr(3, 2);
strYear2= strDate2.substr(6, 4);
venddate = strYear2 + strMonth2 + strDay2;

			//alert(venddate);
			//alert(vstartdate);

	if (venddate < vstartdate)
	{
			
		alert ("[Activity End Date] should be equal to or greater than [Activity Start Date]");
		theform.enddate.focus();
    	return (false);
	}

	if (theform.activity_name.value == "" || theform.activity_name.value==null)
	{
		alert ("Please enter the [Activity Name]");
		theform.activity_name.focus();
    	return (false);
	}
	
	if (theform.activity_type.value == "" || theform.activity_type.value==null)
	{
		alert ("Please select the [Activity Type]");
		theform.activity_type.focus();
    	return (false);
	}
	if (theform.cpd_hour.value.length != "") 
		{      
		 if (IsNumeric(theform.cpd_hour.value) == false) 
	      {
	      alert("Please enter numeric value in [CPD Hour]");
	      theform.cpd_hour.focus();
    		return (false);

	      }	
	      
	     }
	if (!theform.consent.checked)
	{
		alert ("Please check the [I agree] box");
		theform.consent.focus();
    	return (false);

	}

	
	

   theform.submit();


}
