Since Yii 1.1.7, client-side validation has been added to the core CActiveForm Widget, so if you're using version 1.1.7 (or more) of Yii you don't need to use this extension to enable client-side validation. ¶
- Yii 1.1.x (or previous versions) - please note that this extension does not support Yii 1.0 branch. If you're using the 1.0.xx branch, download JFormValidate v 188.8.131.52
This release includes both the extension itself, and a set of sample controller/views dedicated to illustrate JFormValidate usage.
- Extract the release file under a temporary folder
- copy the
extensionsfolder into your app
Please refer to the enclosed README.html file for a complete description.
See the following code example from a sample view file.
<?php // initialize form validation. echo EHtml::beginForm(); // you may now buid your form. Note that call to CHtml helpers // methods are replaced by the ones provided by the extension ?> <div class="simple"> <?php echo CHtml::activeLabelEx($model,'username'); ?> <?php echo EHtml::activeTextField($model,'username') ?> </div> <?php // at the end of the form, call endForm() echo EHtml::endForm(); ?>
And that's it ! ... you form will now be validated on the client browser, based on the rules defined by the Yii model (and supported by this extension).
Please note that since version 1.1.0, this extension can only be used with the EHtml helper class (and not as an application component anymore).
Change Log ¶
February 14, 2010 ¶
- version 1.1.0 - Yii 1.1 support
- no need to call EHtml::setScenario as scenario is get directly from the model
- reduce dependencies between the EJFValidate component and CHtml Yii helper class. Note that CHtml::activeName(), CHtml::activeId, CHtml::encode and CHtml::normalizeUrl are still directly called by the extension, but all other calls have been moved to EHtml. It is not possible anymore to directly use the underlying application component, EHtml must be used instead.
December 6, 2009 ¶
- version 1.0.9
- fix : now the require validator has same behaviour on server and client side, for checkboxes. To validate that a checkbox is checked or not, user should used 'compare' with 'compareValue' set to 1 or true (checked), 0 or false for unchecked ( mh469).
- fix : when the form is submited, a checkbox with no rule remains with its normalized names. This is because name restoration occurs in the JQuery Validate onSubmit Handler. Fix = name is normalized only when a JS rule is actually defined fot the attribute ( mh469).
- enh : is a regexp can't be evaluated on client side, match rule returns 'true', so JS form validation can continue. The regexp will be tested by server-side only ( mh469).
- fix : when using ajaxSubmitButton, url parameters was ignored (makro)
- enh : added support for parameter 'requiredValue' for the 'required' validator (since yii 1.0.10).
- clean up form samples.
November 7, 2009 ¶
- version 1.0.8
- add : added the 'match' validator (regular expression) - added form15 to the sample App
- update : original jquery.validate.js file was modified in order to make it compliant with JS compressors. In particular, opening and closing braces were added to single 'if' statement (thanks to scythah).
- update : getCurrentFormId() is now public
August 29, 2009 ¶
- version 1.0.7
- fixed : js validation rules are not correctly applied when scenario is used (thanks to Jaime)
- fixed : EHtml::setScenario() and EJFValiudate->setScenario() now forward new scenario to CHtml::scenario (thanks to mindeh)
- update : modify form11 so onfocusout and onkeyup are active
June 14, 2009 ¶
- version 1.0.6
- update : sample App (add form13 to illustrate how to create new validators on both client and server side).
- update : now EHtml::endForm() and EJFValidate.endForm() always return tag . Consequently all forms should be updated and closing form tag removed.
- update : add EJFValidate.beginForm()
- new : ajax submit suport - EHtml::ajaxSubmitButton method wraps CHtml::ajaxSubmitButton and supports all its functionnalities
- update : jquery.jfvalidate.helper.js is updated so when a form needs to be normalized, function $.fn.EJFValidate.uniqueName() is invoked on ajax request completed.
April 16, 2009 ¶
- version 1.0.5
- fix : call to methode_exists() (line 262)
- fix : Undefined index: notInt (line 369) In mode error_reporting(E_ALL) these two warning were raised (thanks to letscode)
April 14, 2009 ¶
- version 1.0.4
- add class EHtml to wrap CHtml (simply extension usage) - replace CHtml:: with EHtml:: to enable client side validation. Note that a call to EHtml::endForm() does include the form closing element.
- fix case sensitivity errors in the sample form app md5 : e4121e4eaa30f30fd41677207b62fd97
March 21, 2009 ¶
version 1.0.3 New feature ------------
- add support for the allowEmpty attribute attached to Yii built-in validators (sample form10)
- rename to lowercase sample demo controller and view folder to avoid case issue. rename nav-bar.php to navbar.php
IN ORDER TO USE SAMPLE, PLEASE MODIFY views/jsvform/navbar.php AND RENAME ROUTE TO Jsvform/TestForm (if you're using Windows plateform; no need to do that. Next release will correct this case error)
March 19, 2009 ¶
version 1.0.2 New feature ------------
- Add support for the NUMERICAL built-in Yii validator. All options are supported (integerOnly, min, max, tooBig, tooSmall).
- add form9 to sample forms. This form illustrate the usage of the numerical validator.
- error message selection for rule compare
- remove message JS initialisation option if empty.
March 14, 2009 ¶
- version 1.0.1 : Initial release.