Notice: 函数 WP_Scripts::localize 的调用方法不正确$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131

Html input属性为number,maxlength不起作用问题解决

问题描述

<input type="text"  maxlength="5" />

效果ok,当

<input type="number"  maxlength="5" />

时maxlength失效,长度可以无限输入

解放方案

<input type="number" oninput="if(value.length>5) value=value.slice(0,5)" />

很简单,搞定!

上一篇 iframe实现Html嵌入Html
下一篇 HTML5触摸事件(touchstart、touchmove和touchend)