Password must have at least one non-alpha character
Use regex pattern ^(?=.{8})(?=.*[^a-zA-Z])
Explanation:
^(?=.{8})(?=.*[^a-zA-Z])
│└──┬───┘└──────┬──────┘
│ │ │
│ │ └ string contains some non-letter character
│ │
│ └ string contains at least 8 characters
│
└ begining of line/string
If you want to limit also maximum length (let's say 16), then use regex pattern:
^(?=.{8,16}$)(?=.*[^a-zA-Z])
Run it through a fairly simple regex: [^a-zA-Z]
And then check it's length separately:
if(string.Length > 7)