Trigger validation of all fields in Angular Form submit

后端 未结 13 1337
悲哀的现实
悲哀的现实 2020-12-08 01:45

I\'m using this method: http://plnkr.co/edit/A6gvyoXbBd2kfToPmiiA?p=preview to only validate fields on blur. This works fine, but I would also like to validate them (and thu

13条回答
  •  醉梦人生
    2020-12-08 02:06

    You can use Angular-Validator to do what you want. It's stupid simple to use.

    It will:

    • Only validate the fields on $dirty or on submit
    • Prevent the form from being submitted if it is invalid
    • Show custom error message after the field is $dirty or the form is submitted

    See the demo

    Example

    If the field does not pass the validator then the user will not be able to submit the form.

    Check out angular-validator use cases and examples for more information.

    Disclaimer: I am the author of Angular-Validator

提交回复
热议问题