1

enter image description here

enter image description here

ng-invalid after selecting date from datepicker, but becomes valid if typed. Please help.

Tirtha
  • 89
  • 9
  • Hope this link may help. http://stackoverflow.com/questions/33017677/angular-ui-date-picker-is-in-invalid-state-when-specified-the-date-format-as-d – Santosh Apr 10 '17 at 13:55

2 Answers2

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
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