Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 如何在MVC4中包含密码强度验证器_Jquery_Asp.net Mvc_Asp.net Mvc 4_Asp.net Ajax - Fatal编程技术网

Jquery 如何在MVC4中包含密码强度验证器

Jquery 如何在MVC4中包含密码强度验证器,jquery,asp.net-mvc,asp.net-mvc-4,asp.net-ajax,Jquery,Asp.net Mvc,Asp.net Mvc 4,Asp.net Ajax,我挣扎了好几天,想找到一种工作密码强度检查的方法,但仍然没有找到解决方案。我有一个AjaxBeginForm在部分视图中提供一些简单的输入 以下是我的看法: @模型入口视图模型 <style> input.input-validation-error, textarea.input-validation-error, select.input-validation-error { background: #FEF1EC; border: 1px solid #CD0A

我挣扎了好几天,想找到一种工作密码强度检查的方法,但仍然没有找到解决方案。我有一个AjaxBeginForm在部分视图中提供一些简单的输入

以下是我的看法: @模型入口视图模型

<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>
}

input.input-validation-error,
textarea.input-validation-error,
select.input-validation-error{
背景:#FEF1EC;
边框:1px实心#CD0A0A;
}
.字段验证错误{
颜色:#C55050;
}
@使用(Ajax.BeginForm(“创建”、“条目”、新的AjaxOptions{HttpMethod=“Post”}))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
@LabelFor(model=>model.Title)
@Html.TextBoxFor(model=>model.Title,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Title)
@LabelFor(model=>model.Username)
@Html.TextBoxFor(model=>model.Username,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Username)
@LabelFor(model=>model.Password)
@Html.TextBoxFor(model=>model.Password,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Password)
@LabelFor(model=>model.Url)
@Html.TextBoxFor(model=>model.Url,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Url)
@LabelFor(model=>model.Description)
@Html.TextAreaFor(model=>model.Description,新的{@class=“form control”})
@Html.ValidationMessageFor(model=>model.Description)
@Html.HiddenFor(model=>model.CategoryId)
}
我尝试过很多方法,包括KendoUI,但都不管用。有什么解决方案的建议吗?

我曾经用这个实现过
希望这对您有所帮助。:)

关于.

关于StringLength和数据类型(DataType.Password)呢


看看这些jquery解决方案:
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)]