Location: PHPKode > scripts > Formcat Class > formcat-class/pro/validators/js_validator_isLength.php
<?
  /**
   * Javascript validator for "isLength" check
   * Perform the validation of "isLength" check
 
   * @param array    $params   params set including following parameters:	
   *                           string   $field    Field to test
   *						   int      $min      Min value
   *                           int      $max      Max value    
   *                           bool     $focus    If error whether focus on the input element (optional)
   * @return string JS function body
   **/ 		
   function js_validator_isLength(&$formcat,$params){
   		extract($params);
   		$message = (empty($message))?sprintf($formcat->defaultErrMsg,$field):$message;
   		$focusStr = $formcat->addFocus($field,$focus);
   		
  		$title = "\n\n //checks input value's length whether in the setting length.\n";
       	if($min!="" && $max!=""){
       		$body = ($optional)?"if((!(fc['".$field."'].value.length>=".$min." && fc['".$field."'].value.length<=".$max.")) && !confirm('$message')){\n":"if(!(fc['".$field."'].value.length>=".$min." && fc['".$field."'].value.length<=".$max.")){\nalert('$message');\n";
			$str= $title.$body.$focusStr."return false;\n}\n";						
			return $str;
		}
    }
?>    
Return current item: Formcat Class