这里我的情况是,如果复选框未选中,则相应的字段将被禁用,然后对于禁用的字段,客户端验证不应在此处执行,例如,如果我取消选中(有父亲)的复选框,则与该复选框相关的字段像父亲的名字,姓氏......所以对于这些字段客户端验证不应该执行。如果我再次选中该复选框,则应执行客户端验证
在这里我的问题是,当我取消选中复选框时,客户端验证也在发生并且表单没有提交,在这种情况下任何人都可以帮助我。这是我的示例代码
<?php echo $form->checkBox($modelFamilyFather, '[1]type', array('id'=>'type', 'checked'=>'checked','onChange' => "
if(this.value==checked)
{
$('#" . CHtml::activeId($modelFamilyFather, '[1]firstname') .
"').removeAttr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather,
'[1]lastName') . "').removeAttr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather, '[1]occupation') .
"').removeAttr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather, '[1]averageMonthlyIncome') .
"').removeAttr('disabled','disabled');
}
else {
$('#" . CHtml::activeId($modelFamilyFather, '[1]firstname') .
"').attr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather,
'[1]lastName') . "').attr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather, '[1]occupation') .
"').attr('disabled','disabled');
$('#" . CHtml::activeId($modelFamilyFather, '[1]averageMonthlyIncome') .
"').attr('disabled','disabled');
}
"))." <label for='Father'>Has a Father</label>";
?>