Yii Framework Forum: Add Method To Yii.validation - Yii Framework Forum

Jump to content

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

Add Method To Yii.validation

#1 User is offline   mojtaba6485 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 26-February 13

Posted 15 October 2013 - 11:56 AM

Hi
In yii.validation.js file is writen:

Quote

This JavaScript module provides the validation methods for the built-in validators.

How add valaidation methods for non built-in validators provided by aurselves.
Is it possible to add such methods in a separation js file?
thanks
0

#2 User is offline   CeBe 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 534
  • Joined: 16-July 10
  • Location:Berlin. Germany

Posted 15 October 2013 - 12:14 PM

Sure, you can create your own validator class just the way as the builtin validators are created.
For clientValidaton you implement the clientValidateAttribute() method.
See for example Booleanvalidator on how it is done.

If your JS code is very short you can return it directly. If it needs another js file you can declare an asset bundle for it and make sure it gets registered like Yii is doing it with "ValidationAsset::register($view);"
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