我有一个razor
应用程序,我想在其中添加视图中的电子邮件验证
<td><input type="text" name="mail" placeholder="[email protected]" required autofocus title="" pattern="/^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/"/> </td>
但是这里我有这个语法错误
"[" Is not valid at the start of a block of code. Only identifiers, keywords, comments, "(" and "{" are valid.
有什么问题?我该如何解决?
尝试使用@@转义@。
如果不是,将其放在“ {”或“(”中并检查。
可以通过两种方式完成:
通过剃刀渲染“ @”:
<input type="email" pattern="^[a-zA-Z0-9._+-]+@("@")[a-zA-Z0-9.-]+\.[a-zA-Z]{2,9}$">
使用HTML编码:
<input type="email" pattern="^[a-zA-Z0-9._+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,9}$">
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句