Trigger validation of all fields in Angular Form submit

后端 未结 13 1363
悲哀的现实
悲哀的现实 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:19

    Note: I know this is a hack, but it was useful for Angular 1.2 and earlier that didn't provide a simple mechanism.

    The validation kicks in on the change event, so some things like changing the values programmatically won't trigger it. But triggering the change event will trigger the validation. For example, with jQuery:

    $('#formField1, #formField2').trigger('change');
    

提交回复
热议问题