deen
deen

Reputation: 67

Accept only inclusive date in HTML

I'm making a simple system and I bumped into this problem. The input field should just accept dates from ex.(January 13, 2003 to March 18, 2014) otherwise when the submit button is clicked with invalid dates an error message will be shown. Can I do that in HTML?

Upvotes: 1

Views: 316

Answers (2)

Superman
Superman

Reputation: 881

Please go to this link and download this jquery UI datepicker. There is also a view source link on this page and you can see the simple usage of it.

Hopefully it will resolve your problem. You will be able to get date in proper format in your input field moreover you can save it too.

Upvotes: 0

Heinzi
Heinzi

Reputation: 172448

No, you cannot do that in HTML. HTML has no built-in support for date validation.

You will have to resort to client-side script or server-side validation.

Surprisingly, yes, you can do validation with HTML5:

<input type="date" min="2003-01-13" max="2014-03-18">

However, browser support is lacking, so you are probably better off using client-side script instead.

Upvotes: 1

Related Questions