VitalyB
VitalyB

Reputation: 12855

Ng-submit ignores the submit button disabled state

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

Answers (1)

Alex Choroshin
Alex Choroshin

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

Related Questions