2013-03-20 48 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()">