Reputation: 12855
Consider the following fiddle: While the textbox are empty, the submit button is disabled and pressing Enter in the textbox does nothing as well. If you fill any text, the submit works as expected. The relevant HTML part:
<form name="form1" ng-submit="submitData()" novalidate>
<input type="text" ng-model="data" required /><br />
<input type="text" ng-model="data" required /><br />
<br />
<button type="submit" ng-disabled="form1.$invalid">Submit</button>
</form>
In this fiddle, there is a strange behavior, however. When the textbox is empty, the submit button is disable, but pressing Enter still causes the submit function to be called. The relevant HTML part:
<form name="form1" ng-submit="submitData()" novalidate>
<input type="text" ng-model="data" required /><br />
<br />
<button type="submit" ng-disabled="form1.$invalid">Submit</button>
</form>
The only difference between these fiddles is that the first one has 2 textboxes and the second one has a single one.
Why does it happen?
Upvotes: 0
Views: 827
Reputation: 6187
After testing it on several browsers, I successfully reproduced this bug on IE. on FF and Chrome it worked , so as you can see it's a browser/version compatibility issue so you'll probably need to handle this issue and write the validation on your own.
check this answer on stackoverflow.
Upvotes: 3