表单验证与标签:跳转到第一个无效选项卡 [英] Form Validation with tabs: jump to first invalid tab

查看:304
本文介绍了表单验证与标签:跳转到第一个无效选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个后续质疑<一个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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆