yii2__
yii2__

Reputation: 177

Get Value of a Radio Button via jQuery in Yii2

In my Yii application i have a radio button. When the left button of the radio button is pressed, the value of field_B should not be bigger than 3999. Here is my code in my model.php (But it's not working):

[['field_B''], 'number', 'max' => 3999 , 'min' => 0000, 'tooBig'=> 'The Value is too big',
'when' => function ($model) {
        return $model->Absatzart;
}, 'whenClient'=> new JsExpression("
    function (attribute, value) {
        return ((!$('#stornierung-absatzart').is(':checked')) && ($('#stornierung-absatzart').val()=='1'));                         
}")],   

Upvotes: 0

Views: 687

Answers (1)

vishuB
vishuB

Reputation: 4261

Try below

[['field_B'],  'number',
    'max' => 3999 ,
    'min' => 0000,
    'tooBig'=> 'The Value is too big',
    'when' => function ($model) {
        return $model->Absatzart;
     },
    'whenClient'=> new JsExpression("
       function (attribute, value) {
          if ($('input[type=radio]:checked') =='1') {
              return true;
          }
       return false;             
    }")
],  

Upvotes: 1

Related Questions