hi
how to use modal in bootstrap
Here I use requiredfieldvalidator when users enter wrong information and click button it will shows an Error
Problem is that when I enter wrong information and click button Modal popup closed and I should again click on ContactUs from menu to show Modal and see Error:
I want when I click button it doesn't close Modal...
What should I do?
I use Modal (bootstrap) in my page below are codes:
<script type="text/javascript">
$(function () {
$('#TH5L1LPMV').hide();
$('#TH5L1LPMPM').hide();
$('#TH5L1LPM11').show();
$('#TH5L1LPM2').hide();
$("#navbarNav li a").click(function () {
if ($(this).text() == "Pricing") {
$('#myModal').modal('show');
}
if ($(this).text() == "ContactUs") {
$('#myModal1').modal('show');
}
});
});
</script>
<div id="collapse">
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a class="navbar-brand" href="#"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link">Contact Us</a>
</li>
</ul>
</div>
</nav>
</div>
<div class="modal fade" id="myModal1">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<div id="btnclose">
<button type="button" class="close" data-dismiss="modal">×</button>
</div>
<div id="btntext">
<asp:label id="Label46" runat="server" cssclass="lablemodal">ContactUs</asp:label>
</div>
</div>
<!-- Modal body -->
<div class="modal-body">
<div id="topadd2M">
<div id="DNCRM1">
<div id="DNCRM">
<asp:label id="Label55" runat="server" cssclass="sMalekNa1C1M"> Name: </asp:label>
<asp:label id="Label56" runat="server" cssclass="sMalekNaM"> *</asp:label>
</div>
<asp:textbox id="TxtName" runat="server" cssclass="txtnameCM" tabindex="1"></asp:textbox>
</div>
<div id="DNCRM1">
<div id="DNCLM">
<asp:label id="Label57" runat="server" cssclass="sMalekNa1CM"> Email:</asp:label>
<asp:label id="Label58" runat="server" cssclass="sMalekNaM"> *</asp:label>
</div>
<asp:textbox id="TxtEmail" runat="server" cssclass="txtmobCM" tabindex="2"></asp:textbox>
</div>
<div id="DnameC4M">
<asp:textbox id="TextBox4" runat="server" cssclass="txtdesCoM" textmode="MultiLine" tabindex="5"></asp:textbox>
</div>
</div>
<div id="topadd3M">
<div id="DnameC6M">
<asp:imagebutton id="ImageButton2" runat="server" imageurl="~/Image/main/sendmessage.png" cssclass="imgSeneMeM" onclick="Imgsend_Click"></asp:imagebutton>
</div>
</div>
<div id="DnameC7M">
<div id="message" class="attenCCM">
<asp:label id="Label63" runat="server" cssclass="lblattenC1M">please enter correct information</asp:label>
<asp:image id="Image15" runat="server" cssclass="imgattenM" imageurl="~/Image/main/atten.png"></asp:image>
</div>
<asp:requiredfieldvalidator display="Dynamic" id="RequiredFieldValidator1" runat="server" controltovalidate="Txtname"></asp:requiredfieldvalidator>
<script type="text/javascript">
function WebForm_OnSubmit() {
var message = document.getElementById("message");
message.style.display = "none";
if (typeof (ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) {
for (var i in Page_Validators) {
try {
if (!Page_Validators[i].isvalid) {
message.style.display = "block";
}
} catch (e) {
}
} return false;
} return true;
}
</script>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
Best regards
Neda