如何在HTML输入文本框中仅允许输入日期格式 [英] How to allow only date format input in HTML input text box

查看:488
本文介绍了如何在HTML输入文本框中仅允许输入日期格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<body>

  DATE: <input type="text" name="date" p



</body>
</html>





我的输入框如上所示,不要使用'input type =Date'和java脚本或其他任何东西。



我想只允许来自文本框的日期格式数据。



我尝试了什么:



只想用HTML实现



my input box is as above, dont want use ' input type="Date" ' and java script or anything else.

I want to allow only date format data from text box.

What I have tried:

want to implement only with HTML

推荐答案

你不能根据你的规格

1.必须只有HTML:没有Javascript

2.必须是输入类型=文本,而不是日期



关于唯一的纯HTML版本将使用3个SELECT字段,分别用于月,日和年。问题是如果没有JS你就不能限制/验证所选择的OPTIONS,最终可能会在2099年2月31日结束



如果这个表单已经提交,你可以轻松构建日期服务器端的格式是你想要的
You cannot based on your specifications
1. Must be HTML only: No Javascript
2. Must be Input type="text", not "date"

About the only pure HTML version would be to utilize 3 SELECT fields, one each for month, date, and year. The problem is that without JS you cannot limit/validate the selected OPTIONS, and could end up with February 31, 2099

If this form was submitted, you could easily construct the date server-side in whatever format you want


这篇关于如何在HTML输入文本框中仅允许输入日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆