The format is “#rrggbb“ where rr, gg, bb are two-digit hexadecimal numbers.

The specified value "" does not conform to the required format. The format is "#rrggbb" where rr, gg, bb are two-digit hexadecimal numbers.解决办法

1、警告原因

在使用input标签做为颜色输入框时在console 控制台弹出警告:The specified value “” does not conform to the required format. The format is “#rrggbb” where rr, gg, bb are two-digit hexadecimal numbers.
下面展示一些 html代码片

<input type="color" id="color-fill" class ="form-control m-0 p-0 mt-1" style="width: 100%; height: 10px" value="">
  • 原因是 type=“color” 的 value类型是rr, gg, bb 而html 中的值是空value=“”。html在加载的时候进行类型匹配时警告但不影响使用。
  • 此种错误比较常见。诸如时间日期类型type=“datetime-local”
<input type="datetime-local" id="tdId_{{i.0}}5" value="{{i.4|date:'Y-m-d H:i'}}"/>

2、解决办法

  • 前面说过出现此种错误的原因,是在加载HTML时类型匹配出现了问题,那问题就好解决了只需在 input[type=color]中使用默认值#ffffff 即可。#ffffff 是默认值或格式。

下面展示一些 HTML代码片

<input type="color" id="color-fill" class ="form-control m-0 p-0 mt-1" style="width: 100%; height: 10px" value="#ffffff">
  • 对于上述日期类型格式
<input type="datetime-local" id="tdId_{{i.0}}5" value="{{i.4|date:'c'}}"/>

datetime-local接受ISO 8601日期格式。根据文档,您可以使用格式字符 c将日期时间对象转换为ISO 8601 format

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

杏雨1969

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值