Selva
Selva

Reputation: 47

start and end date validation in HTML5

I am new to HTML5. I want to select start and end dates in my textbox which is input type date. start date must disable future dates and end date should enable greater than start date.

Upvotes: 2

Views: 15360

Answers (3)

int32_t
int32_t

Reputation: 6150

We can set value of the start date to min attribute of the end date.

start.addEventListener('change', function() {
    if (start.value) end.min = start.value;
}, false);

Demo

Upvotes: 4

user2811184
user2811184

Reputation:

I would recommend using JQuery for date validation. JQuery is a JavaScript library, here is a good date range picker for you to get started.

http://jqueryui.com/datepicker/#date-range

Upvotes: 0

Daniel Hutton
Daniel Hutton

Reputation: 1455

You could use the Parsley JS plugin for this. I've used it in several projects and it's great for setting up quick & precise validation.

Parsley JS

Upvotes: 0

Related Questions