javascript - how to unhidden field base on the field validation in yii2 -


i have field set hidden , want unhidden field based on other field validation. how can using jquery??

here code:

<?php $form = activeform::begin([ 'id' => 'assign-form', 'enableajaxvalidation' => true, 

]); ?>

<?= $form->field($volunteeringin, 'acid', [     'template' => '{label} <div class="row"><div class="col-md-5">{input}{error}{hint}</div></div>', ])->dropdownlist($model->getactivitysearch(),['prompt'=>'בחר פעילות לשיבוץ המתנדב'])->label('פעילויות לשיבוץ')?>  <?= $form->field($volunteeringin, 'passedtraining')->radiolist([0=>'לא',1=>'כן'] ,['separator' => '</br>','class'=>'hidden','id'=>'demo'])->label('האם המתנדב עבר הכשרה?'); ?>   <div class="form-group">     <?= html::submitbutton( 'שבץ מתנדב' ,['class' =>  'btn btn-success' ]) ?> </div>  <?php activeform::end(); ?> 

i want set field "passedtraining" unhidden base on the above field validation. try use function:

   $('#fieldid').on('aftervalidateattribute', function(event, attribute, messages) {         if(messages.length == 0){             $('#demo').removeclass('hidden');         }     }); 

thanks eli

i tested code, , have small error:

<?php $form = activeform::begin([     'id' => 'assign-form',     'enableajaxvalidation' => true,     'enableclientvalidation' => true, // enable this! ]); ?> 

hope helps!


Comments

Popular posts from this blog

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -

javascript - oscilloscope of speaker input stops rendering after a few seconds -