Yii Framework Forum: Optional Validation Of A Field - Yii Framework Forum

Jump to content

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

Optional Validation Of A Field Rate Topic: -----

#1 User is offline   Saad Mohsin 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 15-May 14

Posted 21 May 2014 - 04:28 AM

HI,
I have a question regarding setting the rules. I have an email textbox and I want to validate it only when the field is not empty. If the field is empty then the rule is skipped. How can I achieve this in Yii.
Thanks in advance.
0

#2 User is offline   phtamas 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 769
  • Joined: 26-February 11
  • Location:Mezőtúr, Hungary

Posted 21 May 2014 - 04:46 AM

Most built-in validator classes (including CEmailValidator) have an allowEmpty property. Just set it to true.
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