Share via


"#" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

Question

Tuesday, April 12, 2016 8:12 AM

var pwd = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[!@#$%^&*()_+])[A-Za-z\d][A-Za-z\d!@#$%^&*()_+]{6,}$/

if i use above regular expression in mvc view then getting error like "#" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

**I need regular expression for strongly type password with at least 1 character, ****at least ****1 letter and ****at least **1 number.

Above regex follow the same match but it's not working in mvc view.

All replies (1)

Tuesday, April 12, 2016 8:23 AM âś…Answered

Hi,

In place of @# try replacing @@#

please check this post: http://stackoverflow.com/questions/3626250/escape-character-in-razor-view-engine