使用Javascript在模态内部的标签上显示错误消息不起作用
using Javascript to display error message on label inside a modal not working
我正在开发一个应用程序,在该应用程序中,我为用户提供了一个选项,只有当他/她输入正确的密码时,才能更改基准年,我使用模式弹出扩展程序:
如果密码匹配,则在文本框中将readonly设置为false,否则在面板中提供错误消息。
<asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" Style="display: none" Width="233px" BackColor="White" >
<p>Password</p>
<br />
<asp:TextBox ID="password" runat ="server"></asp:TextBox>
<br />
<label id="error" runat="server"></label>
<div>
<asp:Button ID="OkButton" runat="server" Text="OK" />
<asp:Button ID="CancelButton" runat="server" Text="Cancel" />
</div>
<br />
<p>If you do not know the password, you may contact a supervisor to receive the password</p>
</asp:Panel>
这是当用户点击OK时被触发的脚本:
<script type="text/javascript">
function onOk() {
var value = document.getElementById
('<%=password.ClientID%>').value;
var password = '<%=ConfigurationManager.AppSettings
["UnlockPassword"].ToString() %>'
if (value == password)
{
document.getElementById
('<%=TxtBase.ClientID%>').readOnly = false;
}
else
{
document.getElementById
("error").value = "Incorrect Password Please Try Again";
}
}
</script>
0x800a138f-JavaScript运行时错误:无法设置未定义或null引用的属性"value"
当我设置ID为"error"的标签以显示错误消息时,我遇到了一个错误,请帮助!!!!我甚至尝试过innerHtml我正在使用(IE)。还有为什么模态在命中else语句后关闭???
您不能在回发后保持模式弹出窗口打开,因为模式是从客户端脚本打开的(我认为是这样),但您可以从服务器调用另一个打开命令。
这篇文章可能会有所帮助:在这里
相关文章:
- ng消息仅在触摸时显示错误,并在错误的初始显示上转换
- ui网格日期单元格过滤器,过滤日期格式导致显示错误的日期
- java脚本的数学方程显示错误的答案
- 如果用户输入的长度小于最小长度,则显示错误消息
- Push方法显示错误
- Javascript设置日期不起作用,显示错误的时间
- 显示错误的Ajax调用无法调试
- 显示错误结果的Javascript
- 分页逻辑显示错误的页码
- 如何显示错误消息
- 表单提交没有'如果为空,则不会显示错误消息
- 使用RecordRTC录制的WebRTC视频在IE和Safari中显示错误
- 如何仅在存在最小值和最大值时才显示错误消息
- AngularJS错误处理:根据错误数组显示错误
- PHP 显示错误的名称值
- 在 api 调用$resource显示错误和成功消息
- 为什么 Angularjs 总是显示错误消息
- 在单选按钮验证中同时显示错误消息
- jQuery'摇动'功能显示错误
- Jquery添加更多和删除冲突并显示错误值