[英]Bootstrap validation with ASP.NET framework 4.5 Web Forms
I have some ASP.NET aspx form that contains: 我有一些ASP.NET aspx表单,其中包含:
<div class="form-group input-group" runat="server" id="div_last_name">
<span class="input-group-addon glyphicon glyphicon-user"></span>
<asp:TextBox ID="TextBox4" CssClass="form-control required" runat="server" placeholder="Last Name"></asp:TextBox>
</div>
<div class="form-group input-group" runat="server" id="div_email" >
<span class="input-group-addon">@</span>
<asp:TextBox ID="TextBox1" CssClass="form-control required" runat="server" placeholder="E-Mail"></asp:TextBox>
</div>
I want to validate using this jQuery, but I don't know how to use it. 我想使用此jQuery进行验证,但我不知道如何使用它。
jQuery(document).ready(function ($) {
$("#btnRegister_Click").click(function () {
var error = 0;
$('input.required').each(function (i, item) {
if ($(item).val() == '') {
$(item).addClass('form-control has-error');
error = 1;
}
else {
$(item).removeClass('form-control has-error');
}
});
if (error) {
return false;
}
});
var min_height = jQuery(window).height();
jQuery('div.col-lg-6 col-lg-offset-3').css('min-height', min_height);
jQuery('div.col-lg-6 col-lg-offset-3').css('line-height', min_height + 'px');
$(".inner", ".boxed").fadeIn(500);
});
Where it says: 它说:
$("#btnRegister_Click")
You need to replace that with the name of your button. 您需要将其替换为按钮的名称。 If it's a regular HTML button, just use the name of your button like:
如果它是常规的HTML按钮,则只需使用按钮名称即可:
$("#nameofbutton")
If you using Server Control, you need to get the unique client id of the button. 如果使用服务器控件,则需要获取按钮的唯一客户端ID。 You can do that using:
您可以使用:
$('#<%= nameofbutton.ClientID %>')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.