Carlo Adap
Carlo Adap

Reputation: 257

HTML 5, ASP.NET 4.5 TextBox TextMode

Good Day, I just want to ask if it's possible to block past dates in TextBox TextMode = "Date"? Thank you guys!

*Update
there is a way to block dates in TextMode="DateTimeLocal"? If I use Date it's okay, but when I changed the TextMode to DateTimeLocal it's not working.

min=TextBoxArrival.Attributes["min"] = DateTime.Now.ToString("yyyy-MM-dd");
This code is working on TextMode="Date"
This code is from : Mr @Darin Dimitrov

Thank you!

Upvotes: 0

Views: 2392

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1039248

You could use the min attribute:

<input type="date" min="2013-02-24" value="2013-02-24" />

There's also a max attribute you could use to restrict the maximum date that could be selected in the field.

Also don't forget that this is not validation. You should make sure that you perform this validation on your server and not rely on client side.

Upvotes: 2

Related Questions