jonsamwell/angular-auto-validate

submission of validation not working

Closed this issue · 9 comments

I'm using v1.18.4 and when I submit a form, if it is pristine, even if there are errors, it submits without validation. If I change a field that needs validation, and submit, then it only shows the validation error on that field, not any of the others even if they are wrong.

I tried copying the demo that's here:
http://jonsamwell.github.io/angular-auto-validate/#demo
And that didn't work either. Then I checked the version it's using, 1.0.17 and then tried that, and at least in that version, it popped up all the errors, albeit it had other issues.

Validation doesn't seem to be working as expected. Can we get a plunker with a current version with an example? All the examples I found where code is posted on the page still use "form-row" as the class rather than form-group and give errors about it. There doesn't seem to be any recent working version I can find.

Funny you posted this - I am actually working on one now! I'll put a link to it on the Readme.md when it is done. The documentation needs a complete overhaul as it is horrible and it is missing lots of stuff like custom form controls, the various form options you can have (forcing validation, disabling validation, validating hidden elements etc). If you fancy help that would be awesome!

I regards to the submitting - It will unless you have a required attribute on the element (this is an angular thing not this library) however, it might be a bug but haven't noticed it and I'm using the latest version in two projects.

I have required on all my fields, but using the latest version, it doesn't pop up the error messages on all the fields like in the demo. I manually changed the source so the default for forceValidation was true, and it still didn't.

Edit: As simple as I can get

<form novalidate="novalidate" ng-submit="test()">
    <div class="form-group">
        <label for="title">Title</label>
        <input type="text" id="title" class="form-control" required ng-model="title"/>
    </div>
    <button>submit</button>
</form>
        $scope.test = function() {
            alert("test");
        };

I'm having the same problem as @phazei

Nice I'm doing a plunkr now so I'll confirm the issue and submit a fix -
sorry if it's not working guys I'll add a couple of unit tests to cover
this.

On Wed, 18 Mar 2015 at 08:41 Martin Irigaray notifications@github.com
wrote:

I'm having the same problem as @phazei https://github.com/phazei


Reply to this email directly or view it on GitHub
#52 (comment)
.

I've tracked it down to a regression between 1.6.22 and 1.8.3. Working on 1.6.22

yes I've just found the issue - v1.18.x had a big change adding form options to allow for lots of different things (disabling validation, validating hidden elements, forcing validation etc) so the force validation (when clicking the submit button) wasn't sending through the right value. I've fixed it now and just writing a couple more unit tests around it then I'll release. Sorry all!

This is now fixed in v1.18.5. I've added a test as well to make sure this doesn't happen again.

https://github.com/jonsamwell/angular-auto-validate/blob/master/tests/services/validationManager.spec.js#L373

Here is a really simple plunker which works with the latest version. I'm going expand this to a fully working demo later today.

http://plnkr.co/edit/3ff7LWduHCedVJZEorv3?p=preview

excellent! thank you! it works now.

Sorry - created a new issue for the demo plunker here #54