asp.net mvc - Use "@" in html5 input pattern attribute with MVC -
does know how can use "@" within pattern attribute on html5 email input having mvc page?
<input type="email" pattern="^[a-za-z0-9._+-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$">
at runtime error:
"[" not valid @ start of code block. identifiers, keywords, comments, "(" , "{" valid.
when use "data-pattern" instead of "pattern" can escape "@@", "pattern" fails too.
thanks in advance :)
it can done 2 ways:
render "@" through razor:
<input type="email" pattern="^[a-za-z0-9._+-]+@("@")[a-za-z0-9.-]+\.[a-za-z]{2,4}$">
with html encode:
<input type="email" pattern="^[a-za-z0-9._+-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$">
Comments
Post a Comment