我在HTML5中使用日期输入类型.它以dd-MM-yyyy格式正确显示.但是,最小值和最大值未正确验证,因为它根据格式yyyy-MM-dd进行验证.我无法更改最小值和最大值验证的格式,任何想法?
<input type="date" name="DateName" id="DateID" min="2000-01-01" max="2100-12-31"/>
Run Code Online (Sandbox Code Playgroud)
Jon*_*uin 17
The attributes value
, min
and max
have the same format for dates. They follow the RFC 3339 where the full data syntax is as:
full-date = date-fullyear "-" date-month "-" date-mday
date-fullyear = 4DIGIT
date-month = 2DIGIT (01-12)
date-mday = 2DIGIT (01-28, 01-29, 01-30, 01-31)
Run Code Online (Sandbox Code Playgroud)
So even if the browser displays you the date in format dd-mm-yyyy
internally it's using this syntax.
Anyway, this HTML5 input type is only supported in Safari, Chrome and Opera.
You can try this Fiddle with invalid dates as 12/12/2014, when you submit the form an error message is displayed.
归档时间: |
|
查看次数: |
19393 次 |
最近记录: |