indrimuska / angular-selector

A native AngularJS directive that transform a simple <select> box into a full html select with typeahead.
http://indrimuska.github.io/angular-selector
MIT License
96 stars 36 forks source link

Support a required attribute for html5 form validation #13

Closed kmturley closed 8 years ago

kmturley commented 8 years ago

At the moment if you add the required attribute to angular-selector, it's not passed to the nested form field template. This mean html5 form validation does to require it to be filled in.

Consider this example:

<form action="/create" method="post">
    <div class="form-group">
        <label for="title">Title</label>
        <input id="title" type="text" placeholder="Enter your title" model="title" required />
    </div>
    <div class="form-group">
        <label for="tags">Tags</label>
        <select id="tags" placeholder="Select multiple" model="tags" multi="true" selector required>
            <option value="item1">Item 1</option>
            <option value="item2">Item 2</option>
            <option value="item3">Item 3</option>
        </select>
    </div>
    <div class="form-group">
        <input type="submit" value="Submit" />
    </div>
</form>

The title field will have html5 form validation, but angular-select will not, even though they both have a required attribute.

indrimuska commented 8 years ago

Yes, adding required attribute won't work for Angular Selector. I will work for a patch.

indrimuska commented 8 years ago

FYI this is now available in v1.2.0. :)

kmturley commented 8 years ago

amazing!! will check it out, I needed this to be able to put a red border around invalid fields