Html 带有字母和-

Html 带有字母和-,html,regex,Html,Regex,我需要一个带有字母和-的regexp,用作输入类型文本的模式验证, 例如: 您可以使用以下模式([A-Za-z\-]+)检查整个输入: <input type="text" name="name" id="name" class="form-control" placeholder="name form" pattern="[A-Za-z\-]+" required="required"> 您确定它能正常工作吗?尝试pattern=“[A-Za-z-]+”您不需要^和$,pat

我需要一个带有字母和-的regexp,用作输入类型文本的模式验证, 例如:


您可以使用以下模式(
[A-Za-z\-]+
)检查整个输入:

<input type="text" name="name" id="name" class="form-control" placeholder="name form" pattern="[A-Za-z\-]+" required="required">


您确定它能正常工作吗?尝试
pattern=“[A-Za-z-]+”
您不需要
^
$
pattern=“[A-Za-z-]+”
就足够了。