如何在BotDetect MVC CAPTCHA文本框中实现bvalidator

时间:2015-10-14 08:45:53

标签: jquery asp.net-mvc

我已经在我的项目中实现了BotDetect MVC CAPTCHA。我想像往常一样验证验证码文本框。我在我的项目中使用bvalidator进行验证。我不知道如何在验证码文本框中实现bvalidator

这是我的观点

 @using (Html.BeginForm("Index", "Login", FormMethod.Post, new { id = "signupform" }))
            {
                <h2>Sign Up</h2>
                <hr class="colorgraph">
                <div class="form-group">
                    <input type="text" name="NewUserFirst_Name" id="NewUserFirst_Name" class="form-control input-lg" placeholder="First Name" tabindex="1" data-bvalidator="required" data-bavalidator-msg="First Name">
                </div>
                <div class="form-group">
                    <input type="text" name="NewUserLast_Name" id="NewUserLast_Name" class="form-control input-lg" placeholder="Last Name" tabindex="2" data-bvalidator="required" data-bavalidator-msg="Last Name">
                </div>
                <div class="form-group">
                    <input type="text" name="Reg_Email" id="Reg_Email" class="form-control input-lg" placeholder="Email" tabindex="3" data-bvalidator="email,required" data-bvalidator-msg="Email">
                </div>
                <div class="form-group">
                    <input type="password" name="NewUser_Password" id="NewUser_Password" class="form-control input-lg" placeholder="Password" tabindex="4" data-bvalidator="minlength[6],required">
                </div>
                <div class="form-group">
                    <input type="password" name="password_confirmation" id="password_confirmation" class="form-control input-lg" placeholder="Confirm Password" tabindex="5" data-bvalidator="equalto[NewUser_Password],required" data-bvalidator-msg="Confirm Password">
                </div>
                <div class="form-group">
                    @{ MvcCaptcha sampleCaptcha = new MvcCaptcha("SampleCaptcha"); }
                    @Html.Captcha(sampleCaptcha)
                </div>
                <div class="form-group">
                    @Html.TextBox("CaptchaCode", null, new { @class = "form-control input-lg", placeholder = "Please enter above code" })
                    @Html.ValidationMessage("CaptchaCode")
                </div>
                <hr class="colorgraph">
                <div class="row">
                    <input type="submit" class="btn btn-primary btn-lg btn-block" value="Register" tabindex="6">
                </div>
            }

浏览器上的我的页面将是

enter image description here

请帮帮我

1 个答案:

答案 0 :(得分:2)

您可以尝试:

 @Html.TextBox("CaptchaCode", null, new  { required = "required" }, { @class = "form-control input-lg", placeholder = "Please enter above code" })