HTML 5,ASP.NET 4.5 TextBox TextMode

时间:2020-12-14 00:57:21

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

美好的一天,我只想询问是否可以在TextBox TextMode =“Date”中阻止过去的日期?感谢你们!

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

*更新有一种方法来阻止TextMode =“DateTimeLocal”中的日期?如果我使用Date就可以了,但是当我将TextMode更改为DateTimeLocal时它不起作用。

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

min = TextBoxArrival.Attributes [“min”] = DateTime.Now.ToString(“yyyy-MM-dd”);此代码正在处理TextMode =“Date”此代码来自:Mr @Darin Dimitrov

Thank you!

谢谢!

1 个解决方案

#1


2  

You could use the min attribute:

你可以使用min属性:

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

还有一个max属性可用于限制可在字段中选择的最大日期。

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.

另外不要忘记这不是验证。您应确保在服务器上执行此验证,而不是依赖客户端。

#1


2  

You could use the min attribute:

你可以使用min属性:

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

还有一个max属性可用于限制可在字段中选择的最大日期。

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.

另外不要忘记这不是验证。您应确保在服务器上执行此验证,而不是依赖客户端。