我很难找到工作密码强度检查器的方法,但仍未找到解决方案。我在部分视图中使用AjaxBeginForm进行一些简单的输入。
以下是我的观点: @model EntryViewModel
<style>
input.input-validation-error,
textarea.input-validation-error,
select.input-validation-error {
background: #FEF1EC;
border: 1px solid #CD0A0A;
}
.field-validation-error {
color: #C55050;
}
</style>
@using (Ajax.BeginForm("Create", "Entry", new AjaxOptions { HttpMethod = "Post" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<div class="editor-label">
@Html.LabelFor(model => model.Title)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Title, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Title)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Username)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Username, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Username)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Password)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Password, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Password)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Url)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.Url, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Url)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Description)
</div>
<div class="editor-field">
@Html.TextAreaFor(model => model.Description, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Description)
</div>
@Html.HiddenFor(model => model.CategoryId)
<div class="modal-footer">
<a href="#" data-dismiss="modal" class="btn">Close</a>
<input class=" btn btn-primary" id="submitButton" type="submit" value="Create" />
</div>
}
我尝试过很多方法,包括KendoUI,但都没有。有任何解决方案的建议吗?
答案 0 :(得分:1)
答案 1 :(得分:1)
StringLength和DataType(DataType.Password)
怎么样?public class RegisterModel
{
[Required]
[Display(Name = "Name")]
public string UserName { get; set; }
[Required]
[StringLength(100, ErrorMessage = "Pass \"{0}\" must have no less {2} chars.", MinimumLength = 8)]
[DataType(DataType.Password)]
答案 2 :(得分:0)
http://www.webappers.com/2007/08/22/jquery-password-strength-meter-with-better-algorithm/
我曾经使用过这个实现过 希望这能帮助你。 :)