开发者

Need help with Zend form textbox validation

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜