Materialize: cannot make the date picker a required field

Created on 30 May 2016  路  5Comments  路  Source: Dogfalo/materialize

how to change date picker to a required field?
I have tried this but does not work




Most helpful comment

All 5 comments

                       <div class="input-field col s6">   
                        <label name="buildDate" class="">Build Date</label>
                        <input id="buildDate" type="text" class="datepicker picker__input" required>                                       
                    </div>

From the datepicker documentation

By default, typing into the input is disabled by giving it a readOnly attribute. Doing so ensures that virtual keyboards don鈥檛 pop open on touch devices. It is also a confirmation that values passed to the server will be of a consistent format.

Because each input is readOnly by default, HTML5 attributes, such as required and pattern, do not get enforced.

You can manually check for the values instead
checkout the example https://jsfiddle.net/9e33kq0q/1/

@anantoghosh - Thanks for the manual check example. Do you know of a way to show the "data-error" defined in the label when it's invalid?

Thanks @anantoghosh !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lpgeiger picture lpgeiger  路  3Comments

ericlormul picture ericlormul  路  3Comments

cope picture cope  路  3Comments

djensen47 picture djensen47  路  3Comments

hartwork picture hartwork  路  3Comments