Yii Framework Forum: Form Validation For Zip Code Or Postal Code - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Form Validation For Zip Code Or Postal Code Rate Topic: -----

#1 User is offline   nguyendh 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 21-March 11

Posted 29 December 2012 - 11:39 PM

Hi guys,

I have a form which shows Zip Code or Postal Code depends on where the user is coming from. I would like to know if Yii has built-in validation for Zip Code or Postal Code.

I am talking about rules declared in rules function in Model. (http://www.yiiframew...alidation-rules)

If there are none built-in zip/postal code, Please guide me on how to create one.

Thank you,
I am new to Yii and this is my blog http://blog.michaelduy.com (deprecated hatadu.wordpress.com) about Yii, Git and PHP.
0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 2,041
  • Joined: 16-February 11
  • Location:Japan

Posted 30 December 2012 - 12:28 AM

You can use CRegularExpressionValidator.
http://www.yiiframew...essionValidator
See the comments at the bottom for the sample codes.
0

#3 User is offline   LastDay 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 06-March 11
  • Location:Russia

Posted 30 December 2012 - 06:22 AM

To complete previous post, here is link to regular expressions for USA / Canada zip code validation - http://geekswithblog.../03/117321.aspx
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users