Email format validation in mvc3 view

2019-07-21 04:11发布

In a View in MVC3 I want to make a jquery function which validates a textbox for an email format, but when I want to write it like this:

    var a = "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"; 

It doesn't work, because MVC thinks @(...) its a Razor code.

How can I do it ?

2条回答
淡お忘
2楼-- · 2019-07-21 04:35

Razor allows you to enter this by typing in double @. Try @@

查看更多
Anthone
3楼-- · 2019-07-21 04:36

@Html.Raw(" var a = "[a-z0-9....")

查看更多
登录 后发表回答