2013-03-20 49 views
0

我是AngularJS的新手。在angularJS中自定义验证

在下面的提琴中,当用户点击“This submit triggers validation。但我想把这个按钮放在页面末尾”按钮。我可以看到警报/错误,但我想显示一个自定义消息,我正在努力做到这一点。

Header inputs: 
    <input type="name" ng-model="sample" required/> 
    <input type="name" ng-model="sampleX" required/> 

    <input type="submit" value="This submit triggers validation. But I wanted to put this button at the end of the page"/> 
</form> 

<hr/> 

Some other form here. Think line items 

<hr /> 
<a class="btn" ng-click="triggerSubmit()">Wanted this submit to trigger the validation to the form on which this button doesn't belong, e.g. trigger to header</a> 

爵士小提琴链接 http://jsfiddle.net/unWF3/6/

谢谢
格利扬巴萨

+0

哪里是小提琴 – 2013-03-20 09:58:34

+0

只是加了小提琴。 – 2013-03-20 10:01:09

回答

2

要禁用本地浏览器添加验证novalidate属性,形成元素:

<form novalidate submit-on="myEvent" ng-submit="onSubmitted()">