public static MvcHtmlString PasswordCrFor <TModel, TProperty>(this HtmlHelper <TModel> helper, Expression <System.Func <TModel, TProperty> > expression , Dictionary <string, object> htmlAttributes, bool checkStrength) { htmlAttributes = htmlAttributes ?? new Dictionary <string, object>(); HtmlModifier.ManageHtmlAttributes(htmlAttributes, StyleKind.TextBox); if (checkStrength) { htmlAttributes.Add("onkeyup", "strenghtChecker(this)"); htmlAttributes.Add("onblur", "hideChecker($(this).next('span'))"); } var memberExp = expression.Body as MemberExpression; var strengthChecker = memberExp.Member.GetCustomAttributes(typeof(StrengthChecker), true); if (strengthChecker.Length > 0) { PasswordChecker validation = new PasswordChecker(); foreach (var item in validation.CreateRelatedValidation()) { htmlAttributes.Add(item.Key, item.Value); } } var htmlPassword = System.Web.Mvc.Html.InputExtensions.PasswordFor(helper, expression, htmlAttributes); TagBuilder stateBuilder = new TagBuilder("span"); return(MvcHtmlString.Create(htmlPassword.ToHtmlString() + stateBuilder)); }