[ACCEPTED]-How to prevent form submit on enter key press using angular JS?-angularjs
Accepted answer
This response is a little late, but this 7 issue just tripped my team up this afternoon 6 - hopefully our experience will help others.
Merely 5 adding attribute type="button"
to your button object 4 will do the trick - no need for any other 3 changes. This is actually a good attribute 2 to add to any button on your form that is 1 not expressly a form submit button.
<button class="close" type="button" ng-click="toggleForm()" title="Close form">×</button>
Remove the 'type="submit"'
from the add button and use 2 ng-click="addTranslation()"
instead. Also remove ng-submit
from the form
tag as 1 follows
<button class="btn btn-primary btn-xs" ng-click="toggleForm()">Add translation</button>
<form class="block form-inline" id="translation_form" ng-show="form">
<h4>
Enter a new translation for this text in {{language | uppercase}}:
<button class="close" ng-click="toggleForm()" title="Close form">×</button>
</h4>
<hr />
<div class="form-group">
<input type="text" class="form-control" ng-model="formData.text" />
<button class="btn btn-primary btn-sm" ng-click="addTranslation()">Add</button>
</div>
</form>
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.