【发布时间】:2017-03-17 08:55:14
【问题描述】:
https://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_input_pattern
在上面的代码中,如果我们将pattern替换为pattern="(W-([0-9]{1,3})KG)?"
预期值的格式为: “W-23KG”
我知道忽略大小写,我们必须使用 (?i)
因此,如果模式更改为 pattern="(W-([0-9]{1,3})KG)?(?i)" ,则接受以下值: “w-23Kg” “W-23KG” “W-23kg”
但是,问题在于它还接受以下值:
<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
Country code: <input type="text" name="country_code" pattern="(W-([0-9]{1,3})KG)?" title="Three letter country code">
<input type="submit">
</form>
<p><strong>Note:</strong> The pattern attribute of the input tag is not supported in Internet Explorer 9 and earlier versions, or in Safari.</p>
</body>
</html>
"w-23kgW-23kgabcdefgh"
【问题讨论】:
标签: javascript html