标题很清楚,我猜?
这是我的日期输入:
<input type="date" id="birthdate" name="birthdate" value="" max="1993-12-07" required/>
在chrome中,我不能使用字段的小箭头输入早于1993-12-07的日期(但如果我自己写日期,我可以)。
在iOS的safari中,聚焦这个字段只会带来一个很好的datepicker。但是,此日期选择器并不局限于"max“属性。那么我该怎么做呢?当然,我有一个服务器端的表单验证,但我也想在客户端实现它。有什么想法吗?谢谢!
发布于 2011-12-08 01:30:41
Safari目前还不支持它。截至2011年11月,只有Opera和chrome支持它。不管怎样,这是http://www.w3.org/TR/html-markup/input.date.html#input.date.attrs.max上的w3spec
您可以在提交或更改时使用js验证。使用您选择的js验证框架。
下面是纯js示例http://www.roseindia.net/answers/viewqa/Ajax/4734-start-date-and-end-date-validation-in-javascript.html。使用最大日期而不是结束日期
有关jquery解决方案,请查看此Validate that end date is greater than start date with jQuery
发布于 2016-08-08 14:44:13
找到动态禁用未来日期的解决方案:
@{ string datestring = DateTime.Now.ToString("yyyy-MM-dd"); }
<input type="date"
required="required"
name="AttendanceDate"
max="@datestring"
class="form-control" />
https://stackoverflow.com/questions/8417199
复制相似问题