如何使用javascript隐藏和显示引导警报而不是使用javascript警报提示我想用户使用引导警报
在我问这个问题之前。我搜索了怎么做,但没有运气!谢谢
这是aspx代码
<div class="alert alert-danger" role="alert" id="alertname" runat="server" visible="false">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<span class="sr-only">Error:</span>
Enter a valid Name
</div>
<input type="text" runat="server" onkeypress="return isAlphaNumeric(event)" class="form-control" id="txtname" placeholder="Signatory Name" />
这是javascript代码(而不是显示javascript警告提示我想显示引导警报)
<script type="text/javascript">
function isAlphaNumeric(e) {
var key;
if (window.event) {
key = window.event.keyCode; //IE
}
else {
key = e.which; //firefox
}
if (!((key > 64 && key <= 90) || (key > 96 && key <= 122) || (key == 32) || (key > 47 && key <= 57) || (key == 8) || (key == 0) || (key == 127))) {
//document.getElementById('alertsignatoryname').style.visibility = 'visible'
//document.getElementById("myP").style.visibility = "hidden";
//alert(" You can enter only characters a to z,A to Z,0 to 9, and Space ");
return false;
}
}
</script>
答案 0 :(得分:0)
你应该能够简单地使用.show()和.hide()(如果使用jquery)
$('#alertname').show();