表单验证与标签:跳转到第一个无效选项卡 [英] Form Validation with tabs: jump to first invalid tab
问题描述
这是一个后续质疑<一个href=\"http://stackoverflow.com/questions/21468664/validation-in-a-form-with-tabs-using-nested-ng-forms\">Validation在使用嵌套NG-形式选项卡的窗体。
this is a follow-up to question Validation in a form with tabs using nested ng-forms.
在此的jsfiddle http://jsfiddle.net/gaby/LRfrY/4/ 我们不会提交,除非所有它的子窗体 $有效
的形式。如何让它跳到第一个无效选项卡,当用户尝试提交?
In this JSFiddle http://jsfiddle.net/gaby/LRfrY/4/ we have a form that won't submit unless all it's subforms are $valid
. How do make it jump to the first invalid tab when the user tries to submit?
推荐答案
好吧,我发现了一个简单的解决方案,所以我会后我的小提琴
Well I found an easy solution so I'll post my fiddle
http://jsfiddle.net/nicolasmoise/LRfrY/5/
您只需在您的提交按钮添加一个 NG-点击
You just add an ng-click
on your submit button
请注意, $ scope.form1 $有效
变量是不确定的,当控制器初始化。
Note that the $scope.form1.$valid
variable is undefined when the controller initializes.
这篇关于表单验证与标签:跳转到第一个无效选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!