Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I disable form validation for ng-click?

I have a form where certain inputs have "required" attribute. I also have a button that adds form fields when clicked, but it always triggers the form validation message when the required fields are not filled out. I only want form validation to trigger for ng-submit and not ng-click. Is this possible?

like image 926
harveyxia Avatar asked Nov 14 '14 07:11

harveyxia


1 Answers

If you have a look at the W3C specification, it would seem like the obvious thing to try is to mark your button elements with type='button' when you don't want them to submit.

The thing to note in particular is where it says

A button element with no type attribute specified represents the same thing as a button element with its type attribute set to "submit"

like image 61
Amit Sharma Avatar answered Oct 03 '22 02:10

Amit Sharma