<?
/**
* Javascript validator for "notEmpty" check
* Perform the validation of "notEmpty" 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_notEmpty(&$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." has been filled\n\n";
$body = ($optional)?"if(fc['$field'].value=='' && !confirm('$message')){\n":"if(fc['$field'].value==''){\nalert('$message');\n";
$str= $title.$body.$focusStr."return false;\n}\n";
return $str;
}
}
?>