问题描述
<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)" />
很简单,搞定!
$l10n 参数必须是一个数组。若要将任意数据传递给脚本,请改用 wp_add_inline_script() 函数。 请查阅调试 WordPress来获取更多信息。 (这个消息是在 5.7.0 版本添加的。) in /data/www/appblog/wp-includes/functions.php on line 6131<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)" />
很简单,搞定!