angularJS中的自定义验证

时间:2013-03-20 09:55:32

标签: angularjs

我是AngularJS的新手。

在下面的小提琴中,当用户点击&#34时;此提交会触发验证。但我想把这个按钮放在页面的末尾" 按钮。我可以看到警报/错误,但我想显示一条自定义消息,我正在努力做到这一点。          

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>

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

谢谢,
Kalyan Basa

1 个答案:

答案 0 :(得分:2)

要禁用本机浏览器验证,请将novalidate属性添加到表单元素:

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