netceteragroup / valdr

A model centric approach to AngularJS form validation
http://netceteragroup.github.io/valdr/
MIT License
153 stars 43 forks source link

Any way of ignoring validation for certain form actions? #104

Closed alimbada closed 8 years ago

alimbada commented 8 years ago

Hi,

I currently have validation working on a form using valdr which works great for the Submit button. However, we also have a Save button on the same form which saves the form details as a draft for later editing and submission. For saving we would like to ignore all validation and post all the values to the server, but unfortunately all invalid fields are coming through to the server as null.

Is there a way to switch off validation for when I need to save?

Thanks,

Ammaar

Edit: I've looked at the valdr-enabled directive, but not sure how to use it from within the AngularJS controller for the form.

philippd commented 8 years ago

Hi Ammaar

valdr-enabled is the way to go. You can expose a property like validationEnabled from the scope of your controller and bind it to the valdr-enabled directive. Then you can set it to false when the user hits save. Let me know if this worked for you!

In the future, please ask support questions like this on StackOverflow as described here: https://github.com/netceteragroup/valdr#support

Regards Philipp