html - md-select - how to force required? -
how force md-select
in multiple mode behave like
<select multiple required ... >
?
here fiddle, show mean. in example, browser doesn't let me submit form without selecting @ least 1 option select tag.
i want md-select behave similarly, don't know how can - neither putting 'required' attribute nor adding 'ng-require' directive helps.
you can rely on angular validation this, rather browser. here's forked example:
http://codepen.io/anon/pen/rvglzv
specifically:
<button type="submit" ng-disabled="myform.$invalid">submit</button>
to keep submit button disabled until form valid and,
<form novalidate name="myform">
to name form , tell browser not own validation on it.
you add css class ng-invalid show red around invalid fields.
edit: make sure put ng-model
on <select multiple>
, otherwise required attribute won't work.
Comments
Post a Comment