【发布时间】:2017-03-20 15:21:28
【问题描述】:
我在 https://captchamvc.codeplex.com/ 的 MVC 项目中使用部分普通验证码,它工作正常,但我想让它成为区分大小写的字母数字验证码。我怎样才能使它区分大小写的字母数字?
部分查看代码
@model CaptchaMvc.Models.DefaultBuildInfoModel
<img id="@Model.ImageElementId" src="@Model.ImageUrl" />
@Html.Hidden(Model.TokenElementId, Model.TokenValue)
<br />
@{
string id = Guid.NewGuid().ToString("N");
string functionName = string.Format("______{0}________()", Guid.NewGuid().ToString("N"));
<script type="text/javascript">
$(function () {
$('#@id').show();
});
function @functionName {
$('#@id').hide();
$.post("@Model.RefreshUrl", { @Model.TokenParameterName: $('#@Model.TokenElementId').val() },
function () {
$('#@id').show();
});
return false;
}
</script>
<a href="#@Model.ImageElementId" id="@id" onclick="@functionName" style="display: none;">@Model.RefreshButtonText</a>
}
<br />
@Model.InputText
<br />
@if (Model.IsRequired)
{
@Html.TextBox(Model.InputElementId, null, new Dictionary<string, object>
{
{"data-val", "true"},
{"data-val-required", Model.RequiredMessage}
})
}
else
{
@Html.TextBox(Model.InputElementId)
}
@Html.ValidationMessage(Model.InputElementId)
查看代码:我在哪里渲染局部视图
<div class="form-group">
<div class="col-sm-9">
@Html.TextBoxFor(model => model.LoginID, new { autocomplete = "off", id = "txtbx_EmailID", maxlength = 100, @class = "form-control", @style = "margin-bottom: 2px;width: 232px;", placeholder = Html.DisplayNameFor(model => model.LoginID) })
</div>
</div>
<div class="form-group">
<div class="col-sm-9">
@Html.PasswordFor(model => model.Password, new { autocomplete = "off", id = "txtbx_Password", maxlength = 100, @class = "form-control", @style = "margin-bottom: 2px;width: 232px;", placeholder = Html.DisplayNameFor(model => model.Password) })
</div>
</div>
<div class="form-group">
<div class="col-sm-9">
@Html.Captcha(5, "_DefaultCaptchaView")
</div>
</div>
<div class="form-group" style="/*padding-left: 15px; */ margin-top: 2px; margin-bottom: 0px;">
<input id="btnSubmit" onclick="PasswordVerification();" name="command" type="submit"
value="Sign in" class="btn btn-success btn-sm btn01" style="width: 110px;" />
@Html.ActionLink("New User", "Registration", "Login", new { @class = "btn btn-default btn-sm btn01" })
</div>
<div style="color: Red; height: 8px;">
@{
if (@ViewBag.LoginFailed == true)
{
<span>@ViewBag.LoginFailedMessage</span>
}
}
</div>
控制器动作代码:
[HttpPost, CaptchaVerify("Captcha is not valid")]
[ValidateAntiForgeryToken]
public ActionResult Login(Login Lobj, string Command)
{
some code to validate login
return View(Lobj);
}
【问题讨论】:
标签: c# asp.net-mvc asp.net-mvc-4 captcha