Here is the code or script for validating controls
<script type="text/javascript">
$(document).ready(function () {
$('input[type = text],input[type = password]').val(''); // not affecting if comment or un-comment
$('#form1').bootstrapValidator({
live: 'disabled',
message: 'This value is not valid',
feedbackIcons: {
//valid: 'fa fa-check',
invalid: 'fa fa-times',
validating: 'fa fa-refresh'
},
fields: {
txt_user_id: {
trigger:'blur',
message: 'The username is not valid',
validators: {
notEmpty: {
message: 'The username is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The username must be more than 6 and less than 30 characters long'
}
}
},
txt_password: {
trigger: 'blur',
message: 'The password is not valid',
validators: {
notEmpty: {
message: 'The password is required and cannot be empty'
},
stringLength: {
min: 6,
max: 30,
message: 'The password must be more than 6 and less than 30 characters long'
}
}
}
},
});
$('#btn_login').click(function () {
$('#form1').bootstrapValidator('validate');
});
$('#btn_cancel').click(function () {
$('#form1').data('bootstrapValidator').resetForm(true);
});
});
</script>
Here is my form
<form id="form1" method="post" runat="server" class="form-horizontal">
<div>
<div class="form-box" id="login-box">
<div class="header">Sign In</div>
<asp:Label ID="lbl_msg" runat="server" Text=""></asp:Label>
<div class="body bg-gray">
<div class="form-group">
<div class="col-md-12">
<asp:TextBox ID="txt_user_id" runat="server" class="form-control" placeholder="User ID" ClientIDMode="Static"></asp:TextBox>
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<asp:TextBox ID="txt_password" runat="server" class="form-control" placeholder="Password" TextMode="Password" ClientIDMode="Static"></asp:TextBox>
</div>
</div>
</div>
<div class="footer">
<asp:Button ID="btn_login" runat="server" Text="Login" ClientIDMode="Static"
class="btn bg-olive btn-sm" onclick="btn_login_Click"/>
<asp:Button ID="btn_cancel" runat="server" Text="Cancel" ClientIDMode="Static"
class="btn bg-olive btn-sm"/>
<p><a href="#">I forgot my password</a><br />
<a href="register.aspx">Sign Up</a></p>
</div>
</div>
</div>
<br />
</form>