Location: PHPKode > scripts > Formcat Class > formcat-class/pro/validators/js_validator_isInt.php
<?
  /**
   * Javascript validator for "isInt" check
   * Perform the validation of "isInt" check
 
   * @param array    $params   params set including following parameters:	
   *                           string   $field    Field to test
   *                           string   $message  Error message used in place of the default one
   *                           bool     $focus    If error whether focus on the input element (optional)
   * @return string JS function body
   **/ 		
   function js_validator_isInt(&$formcat,$params){
   		extract($params);
   		$message = (empty($message))?sprintf($formcat->defaultErrMsg,$field):$message;
   		$focusStr = $formcat->addFocus($field,$focus);
 		if(!empty($field)){
	   		$title = "\n\n// checks if ".$field." is interger\n";
	   		$body = "var validChar = '0123456789';\n".
	        	   "var i;\n".
	        	   "for (i = 0; i < fc['".$field."'].value.length; i++){\n".
	        	   "var c = fc['".$field."'].value.charAt(i);}\n";
							        	   
	        $body.=($optional)? "if((validChar.indexOf(c)==-1) && !confirm('$message')){\n":"if(validChar.indexOf(c) == -1) {\nalert('$message');\n";
	   		       
			$str= $title.$body.$focusStr."return false;\n}\n";			   		       
	        return $str;
	    }
    }

?>
Return current item: Formcat Class