【发布时间】:2015-07-11 13:25:50
【问题描述】:
字段:
- 字段
f1:文件上传输入字段(我使用的是自定义角度指令) - 字段
f2:评论文本区域字段
现在,有一个单选按钮“是”和另一个“否”
伪代码 -
on selecting "yes":
{
"f1" appears and is a required field
and
"f2" stays invisible and disabled and not a required field
}
while
on selecting "no":
vice versa
最后的条件是提交按钮禁用,以防我在选择“是”时不上传文件 或者如果我在选择“否”时没有填写评论字段
注意:为了清楚起见....f1 是必需的、启用的和可见的,或者 f2 是。
<input type="radio" ng-model="check" value="yes">yes
<input type="radio" ng-model="check" value="no">no
<input type="file" ng-disabled="check == 'no'" ng-required="check == 'yes'" ng-show="check == 'yes'">
<input type="textarea" ng-disabled="check == 'yes'" ng-required="check == 'no'" ng-show="check == 'no'">
<input type="submit" ng-disabled="form.$error.required" value="submit">
【问题讨论】:
-
ng-if和ng-required我相信应该这样做。 -
这个网站是关于不为你编写代码的答案。您必须展示您已尝试过的内容以及您已尝试对问题进行合理的自我研究。到时候如果需要就问一个问题,但不要只是让别人为你写代码。
-
对不起,伙计……但我也付出了我的责任……当我检查我的页面时,它似乎在 html 内部运行良好,但它没有反映在页面上
-
@PatrickW.McMahon...我不能把我的完整代码放在这里...它用于商业目的和机密
标签: javascript jquery html angularjs forms