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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -