html 模式属性

问题描述 投票:0回答:1

我试图将我的文本输入限制为仅允许字母,而不是数字。最多 100 个字符。我无法找出如何使用模式属性仅允许字母。这是我尝试此操作的代码的一部分。

<form action="http://www.severien.com/grit/formecho.php" method="post" target="_blank">
        <label for="videorequests"> Video Requests:</label>
        <input type="text" id="videorequests" name="videorequests" maxlength="100" pattern="[a-z]{1,100}" />
        <input type="submit" value="Submit" class="submitbutton" />
    </form>

使用属性 maxlength 我将字符输入限制为 100。如何使用模式将字符限制为仅使用字母,不包括数字字符?

html regex attributes
1个回答
1
投票

用这个

pattern="[A-Z a-z]{1,100}" 
© www.soinside.com 2019 - 2024. All rights reserved.