javascript - Dynamic Form validation in yii -


i can't seem javascript form validation working in yii

i want point script towards user form , include in clientoptions it's saying validateform not defined.

i tried default functionality working there doesn't seem anyway validate dynamically created fields in yii without creating own function this. know fields particular instance can put them in manually now

$form = $this->beginwidget('booster.widgets.tbactiveform', array(     'id' => 'user-form',     'enableajaxvalidation' => true,     'clientoptions' => array(         'validateonchange' => false,         'validateontype' => false,         'validateonsubmit' => 'js:validateform',     ),         )); ?>      <?php $varform = new dynamicform(); $varform->attributes = $user->getdynamicformconfig(); $varform->model_name = 'user'; echo $varform->run(); ?> 

js

function validateform()     {     var a=document.forms["#user-form"]["user_testquestion"].value;     var b=document.forms["#user-form"]["user_newquestion"].value;      if (a==null || a=="",b==null || b=="")       {       alert("please fill required field");       return false;       }     } 

validateonsubmit boolean parameter. if want fields on validation may use:

  1. beforevalidate function, function invoked before performing ajax-based validation triggered form submission action (available when validateonsubmit set true). expected function signature should beforevalidate(form) {...}, 'form' jquery representation of form object. if return value of function not true, validation cancelled.
  2. aftervalidate function, function invoked after performing ajax-based validation triggered form submission action (available when validateonsubmit set true). expected function signature should aftervalidate(form, data, haserror) {...}, 'form' jquery representation of form object; 'data' json response server-side validation; 'haserror' boolean value indicating whether there validation error. if return value of function not true, normal form submission cancelled.

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -