Cosmin Grigore
Cosmin Grigore

Reputation: 113

Email format validation in mvc3 view

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 ?

Upvotes: 2

Views: 531

Answers (2)

CR41G14
CR41G14

Reputation: 5594

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

Upvotes: 2

Anri
Anri

Reputation: 6265

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

Upvotes: 0

Related Questions