Trigger validation without ng:submit

1,805 views
Skip to first unread message

Johan Steenkamp

unread,
Nov 7, 2011, 5:46:10 PM11/7/11
to ang...@googlegroups.com
I have a form with required fields, and three submit buttons each taking a different action.

Using ng:submit on form the angular validation (0.10.4) will be displayed without the form submitting.

However if I use the button with ng:click="buttonAction()" to process the form the validation happens after the button action.

I'm sure I can do this by setting an action in the model via button and using ng:submit but be interested to know how.

Suggestions?

Igor Minar

unread,
Nov 8, 2011, 1:26:45 AM11/8/11
to ang...@googlegroups.com
can you describe your use case?

typically the validation should make action buttons enabled/visible or disabled/hidden. Validating the form as a result of clicking on a button sounds too late, but maybe you have a use case that we overlooked.

btw it should be possible to triggered validation manually by firing a $validate event on the scope with which the form is linked (this typically happens automatically).

/i


--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To view this discussion on the web visit https://groups.google.com/d/msg/angular/-/ClrDnFHJyYoJ.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/angular?hl=en.

Johan Steenkamp

unread,
Nov 8, 2011, 2:59:35 PM11/8/11
to ang...@googlegroups.com
Thanks Igor - I was being mislead by native browser validation overlays displaying on submit in chrome/firefox. I thought it was strange as I had not seen these overlays mentioned/shown in angular docs.

You are correct - the buttons should be disabled for invalid form.

Thanks for pointing out #validate event.
Reply all
Reply to author
Forward
0 new messages