Zend_valdiate_alpha combined with special characters
Zend_valdiate_alpha combined with special characters
Need to combine An alphanumeric character or underscore with string . for example : need to add control for City nam开发者_如何学Goe with
not necessary with zend_alpha it can be another way
any suggestions ??
I have exactly the same problem. I need to allow commas, alphas, and whitespaces. The most simple solution, I can think of, is to define callback validation function like this:
$myValidator = new Zend_Validate_Callback(function($value) {
$value = preg_replace('/,/', '', $value);
$alphaValidator = new Zend_Validate_Alpha(array('allowWhiteSpace' => true));
if ($alphaValidator->isValid($value)) return true;
return false;
});
And using it like this:
if ($myValidator->isValid($input)) {
// input valid
} else {
// input invalid
}
I know this is old but perhaps it can help somebody and I would be interested if there is a simpler solution.
精彩评论