javascript - Visual studio 12 and regular expressions error -
i getting strange error in vs2012.
i've got following script:
<script type="text/javascript"> function validateemail($email) { var emailreg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailreg.test( $email ) ) { return false; } else { return true; } } </script>
this throws sot of errors in ide, , in vs2010 used run ok.
what wrong?
thanks!
let me guess... using razor (a cshtml page)? if so, problem caused because ide thinks part @([\w-]+\.)
razor expression , then, javascript reg ex looking missing parenthesis. fix this, need escape @
using @@
code be:
<script type="text/javascript"> function validateemail($email) { var emailreg = /^([\w-\.]+@@([\w-]+\.)+[\w-]{2,4})?$/; if( !emailreg.test( $email ) ) { return false; } else { return true; } } </script>
Comments
Post a Comment