我的脚本不起作用
My script is not working
我在"保存"按钮中调用脚本函数,以在特定文本字段为空时显示警报。
脚本:
function validateAddRootCaseForm() {
if (document.getElementById(GetClientId("txtRoot"))) {
if (document.getElementById(GetClientId("txtRoot")).value == "") {
alert("Root is mandatory");
return false;
}
}
if (document.getElementById(GetClientId("txtDes"))) {
if (document.getElementById(GetClientId("txtDes")).value == "") {
alert("Description is mandatory");
return false;
}
}
}
前端代码:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
<table class="style1">
<tr>
<td class="style2">
<asp:Label ID="lblRootCaseID" runat="server" Text="Root Cause ID"></asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtRootCaseID" runat="server" Height="25px" Width="260px" ReadOnly="true"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="lblRootDes" runat="server" Text="Root"> </asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtRoot" runat="server" Height="25px" Width="260px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr>
<td class="style2">
<asp:Label ID="lblDes" runat="server" Text="Description"> </asp:Label>
</td>
<td class="style6">
<asp:TextBox ID="txtDes" runat="server" TextMode="MultiLine" Rows="10" Width="260px"></asp:TextBox>
</td>
<td>
</td>
</tr>
<tr style="visibility: hidden">
<td>
</td>
</tr>
<tr style="visibility: hidden">
<td>
</td>
</tr>
<tr>
<td class="style5">
</td>
<td style="height: 30px">
<asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="return validateAddRootCaseForm()"
Width="80px" Height="25px" OnClick="btnSave_Click" />
<asp:Button ID="btnAddNew" runat="server" Text="Add New Root Case" Width="150px" Height="25px"
OnClick="btnAddNewRootCase_Click" />
<br />
<br />
<br />
</td>
</tr>
</table>
但是,当我单击带有空字段的"保存"按钮时,这些警报不会显示。有人能帮我解决这个问题吗。
尝试从按钮调用中删除"return"
相关文章:
- 当有许多形式时,Fancybox脚本不起作用
- Aureliaview中的脚本不起作用
- JQuery脚本在IE中不起作用
- 淡入淡出脚本不起作用
- 未捕获的类型错误:无法设置属性'innerHTML'如果为null,则将脚本移动到正文不会;不起作用
- jQuery脚本在googlechrome中不起作用
- 替换字符串的脚本;在某些网站上不起作用
- 从jquery对话框恢复原始数据,脚本不起作用
- java脚本中的谷歌地图在第二次点击时不起作用
- 我的脚本不起作用
- JavaScript onScroll在谷歌应用程序脚本web应用程序中不起作用
- 为什么锚在此脚本中不起作用
- getRange(单元格)在谷歌应用程序脚本中不起作用
- 脚本在我的引导模式中不起作用
- 用于wooccommerce的简单JQuery脚本不起作用
- 对照数组脚本检查文本框中的值不起作用
- 脚本在IE 9中不起作用
- 如果视图中没有Jquery脚本引用,Unobtrusive Javascript Validation是不起作用的
- Codeigniter :通过 AJAX 调用 php 脚本时路由不起作用
- 谷歌转化不起作用 - 脚本无法加载