this is the solution i used , if anyone will face the same problem : * its a custom validator which implements only the client side
class EspecialValidator extends CValidator {
public $message;
public $compareValue;
/**
* Validates the attribute of the object.
* If there is any error, the error message is added to the object.
* @param CModel the object being validated
* @param Array the attribute being validated
*/
protected function validateAttribute($object, $attribute) {
parent::validateAttribute($object, $attribute);
}
/**
* Returns the JavaScript needed for performing client-side validation
* @param type $object
* @param type $attribute
*/
public function clientValidateAttribute($object, $attribute) {
$js = '
if($.trim(value)=="' . $this->compareValue . '") {
messages.push("' . $this->message . '");
}
';
return $js;
}
}
from the rules , use it in the following:
array('fieldToCheck', 'ext.validators.EspecialValidator', 'compareValue' => 'TextToCompare', 'message' => 'failure message')