开发者

Need help with Zend form textbox validation

开发者 https://www.devze.com 2023-02-16 03:34 出处:网络
Currently Im developing a website with Zend framework. I need help with my suburb name validation I need the validation to check if the input is in the following format

Currently Im developing a website with Zend framework.

I need help with my suburb name validation

I need the validation to check if the input is in the following format

Suburb Name comma symbol space State abbreviations (State abbreviations consi开发者_如何学JAVAst exact three letters)

Example: MANLY, NSW or SYDNEY, NSW or PALM BEACH, QLD

Basically I need to validate in this format? So how can i do it in Zend framework? Do I need to write custom Zend form validation?

Thanks so much in advance :D


You can use Zend_Validate_Regex for it. Example:

$myValidator = new Zend_Validate_Regex('/^([a-zA-Z]+),\s(NSW|ACT|VIC|QLD|SA|WA|TAS|NT)$/');
$myValidator->setMessage('Your validation message goes here', Zend_Validate_Regex::NOT_MATCH);

Then add validator to your field.

0

精彩评论

暂无评论...
验证码 换一张
取 消