Your question is quite ambigious since you did not mention if you're using Web Forms or MVC. Nevertheless, you can use client-side validation in javascript with
RegEx.test method since it can be used in both Web Forms and MVC.
var hasError = false;
var password = $('#password').val();
if (password.length > 0) {
var passwordTest = new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[~`!@#\$%\^&\*,.])(?=.{8,})');
if (!passwordTest.test(password)) {
hasError = true;
}
}
RegEx Description:
^ The password string will start this way
(?=.*[a-z]) The string must contain at least 1 lowercase alphabetical character
(?=.*[A-Z]) The string must contain at least 1 uppercase alphabetical character
(?=.*[0-9]) The string must contain at least 1 numeric character
(?=.*[!@#\$%]) The string must contain at least one special character
(?=.{8,}) The string must be eight characters or longer