Location: PHPKode > scripts > Formcat Class > formcat-class/pro/validators/js_validator_isDate.php
<?
  /**
   * Javascript validator for "isDate" check
   * Perform the validation of "isDate" check
 
   * @param array    $params   params set including following parameters:	
   *                           int      $year     Year Field to test
   *                           int      $month    Month field to check
   *                           int      $day      Day field to check
   * @return string JS function body
   **/ 		
   function js_validator_isDate(&$formcat,$params){
   		extract($params);
   		$message = (empty($message))?sprintf($formcat->defaultErrMsg,"The inputed DATE"):$message;
   		if($year!='' && $month!='' && $day!=''){
	   		 $str = "\n\n// checks if ".$field." is date\n";
	   		 $str.= "var year = fc['".$year."'].value;\n".
	   		        "var month = fc['".$month."'].value;\n".
	   		        "var day = fc['".$day."'].value;\n".
	   		        "var tempDate = new Date(year,month,day);\n".
	   		        "var realyr = tempDate.getYear();\n".
	   		        "var realm = tempDate.getMonth();\n".
	   		        "var reald = tempDate.getDate();\n";
				   		        
	   		 $str.=($optional)?"if ((year!=realyr || month!=realm || day!=reald) && !confirm('$message')){\nreturn false;\n}\n":"if (year!=realyr || month!=realm || day!=reald){\nalert('$message');\nreturn false;\n}\n";
	   		        
	   		 return $str;
	   }
	}

?>
Return current item: Formcat Class