<?php
class FxNotNullValidator
{
public static function validator($control, $style = '')
{
$style = $style == '' ? "style = 'color:#ff0000'" : $style;
return "<span id='____NOT_NULL_VAL_".$control."____' ".$style."></span>";
}
public static function validatorScript($control, $errMsg, &$funcName)
{
$funcName = "____notNullValidatorJS_".$control."____()";
return "
function ____notNullValidatorJS_".$control."____()
{
if(document.getElementById('".$control."').value == '')
{
document.getElementById('____NOT_NULL_VAL_".$control."____').innerHTML = '".$errMsg."';
return false;
}
else
{
document.getElementById('____NOT_NULL_VAL_".$control."____').innerHTML = '';
return true;
}
}";
}
}
class FxRegExpValidator
{
public static function validator($control, $style = '')
{
$style = $style == '' ? "style = 'color:#ff0000'" : $style;
return "<span id='____REG_EXP_VAL_".$control."____' ".$style."></span>";
}
public static function validatorScript($control, $regExp, $errMsg, &$funcName)
{
$funcName = "____regExpValidatorJS_".$control."____()";
return "
function ____regExpValidatorJS_".$control."____()
{
if(!document.getElementById('".$control."').value.match(".$regExp."))
{
document.getElementById('____REG_EXP_VAL_".$control."____').innerHTML = '".$errMsg."';
return false;
}
else
{
document.getElementById('____REG_EXP_VAL_".$control."____').innerHTML = '';
return true;
}
}";
}
}
?>