ng-invalid after selecting date from datepicker, but becomes valid if typed. Please help.
Asked
Active
Viewed 1,362 times
2 Answers
1
ng-invalid
class is added from angular when a required field is invalid (e.g empty), make sure the ng-model
relative field , formvalue.workshopeDate
, is correctly populated when you trigger the click.

Karim
- 8,454
- 3
- 25
- 33
-
Well formvalue.workshopeDate is empty on load. It will be used to get the value in button click. – Tirtha Apr 10 '17 at 14:02
-
1
I worked around this by hiding the datepicker and showing an empty input text field when the value is null and then swapping/showing the datepicker when it is clicked.
<input
ng-if="my_date || set_my_date"
type="text"
id="my_date"
name="my_date"
datetime-picker="MM/dd/yyyy h:mma"
is-open="my_date"
ng-focus="set_my_date = true"
class="form-control"
ng-model="my_date"
placeholder="my date"
ng-readonly="true"
ng-required="true"
/>
<input
ng-if="!my_date && !set_my_date"
class="form-control"
placeholder="my date"
ng-click="set_my_date = true"
/>

doublesharp
- 26,888
- 6
- 52
- 73