1

For some reason, I don't have datepicker for the date input field and I want to allow to enter value in mm/dd/yyyy format only. I've used parsley js for validation.

Somehow, I've managed to validate email, image, digits field and i don't find built in validation method for date.

Is there any parsley rule for the date ?

Sagar Gautam
  • 9,049
  • 6
  • 53
  • 84

1 Answers1

1

Yes, there is. It's unfortunately not documented but it was added in version 2.7 according to the CHANGELOG

The date parse code is here

It expects YYYY-MM-DD so you could do something like

<input type="text" id="somedate"
       placeholder="YYYY-MM-DD"
       data-parsley-type="date"
       data-parsley-type-message="Date must be YYYY-MM-DD"
       data-parsley-mindate="{{ today|date:'Y-m-d' }}"
       data-parsley-mindate-message="Date must be after today"
       required>
timbo
  • 13,244
  • 8
  • 51
  • 71