我希望用户只输入十位数字而无需标点符号。我已经尝试过以下模式。在每种情况下,都会弹出一个窗口要求我“请匹配请求的格式”。我可能会切换到 jquery 解决方案,但我仍然很好奇为什么这不起作用?
感谢您的任何见解,苏
<label for="cellPhone">
<g:message code="employees.cellPhone.label" default="Cell Phone" />
</label>
<g:field type="text" pattern="~/[0-9]{10}/" name="cellPhone1" placeholder="10-digit cell including area code" ></g:field>
<g:field type="text" pattern="~[0-9]{10}" name="cellPhone2" placeholder="10-digit cell including area code" ></g:field>
<g:field type="text" pattern="~/\\d{10}/" name="cellPhone3" placeholder="10-digit cell including area code" ></g:field>
<g:field type="text" pattern="~\\d{10}" name="cellPhone4" placeholder="10-digit cell including area code" ></g:field>
<g:field type="text" pattern="~/\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d/" name="cellPhone5" placeholder="10-digit cell including area code" ></g:field>
<g:field type="text" pattern="~\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d" name="cellPhone6" placeholder="10-digit cell including area code" ></g:field>