Email format validation in mvc3 view

核能气质少年 提交于 2019-12-24 00:35:43

问题


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 ?


回答1:


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




回答2:


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



来源:https://stackoverflow.com/questions/12533283/email-format-validation-in-mvc3-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!