【发布时间】:2015-01-18 20:47:58
【问题描述】:
这是我的代码:
asp.net:
<table>
<tr>
<td class="td1" colspan="2" style="width:100%;text-align:center;border-top-left-radius:10px;border-top-right-radius:10px">Make Payment</td>
</tr>
<tr>
<td class="td1" title="Payment Mode">Payment Mode:</td>
<td class="td2">
<asp:RadioButtonList ID="rblpaymentmode" runat="server" CssClass="lbidname" RepeatDirection="Horizontal" ToolTip="Select Payment Mode" OnSelectedIndexChanged="rblpaymentmode_SelectedIndexChanged" AutoPostBack="True" CausesValidation="True">
<asp:ListItem>Cheque</asp:ListItem>
<asp:ListItem>Cash</asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td class="td1" title="Member Name">Member:</td>
<td class="td2">
<asp:DropDownList ID="ddlmember" runat="server" CssClass="ddl" ToolTip="Select Member">
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="td1" title="Particular Type">Particular Type:<br />
<br />
<asp:Label ID="lbenterdetails" runat="server" Text="Enter Details:" ToolTip="Enter Details:" Visible="False"></asp:Label>
</td>
<td class="td2">
<asp:RadioButtonList ID="rblparticulartype" runat="server" CssClass="lbidname" RepeatDirection="Horizontal" OnSelectedIndexChanged="rblparticulartype_SelectedIndexChanged" ToolTip="Select Particular Type" AutoPostBack="True" CausesValidation="True">
<asp:ListItem Selected="True">Yearly Lawaazam</asp:ListItem>
<asp:ListItem>Other</asp:ListItem>
</asp:RadioButtonList>
<asp:TextBox ID="txtotherparticulartype" runat="server" CssClass="textbox" ToolTip="Enter Details" Width="90%" Visible="False"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td1" title="Cheque Date">Cheque Date:</td>
<td class="td2">
<asp:TextBox ID="txtchequedate" runat="server" CssClass="textbox" Width="90%" ToolTip="Select Cheque Date"></asp:TextBox>
<asp:CalendarExtender runat="server" ID="cetxtchequedate" CssClass="cal_Theme1" PopupPosition="Right" TargetControlID="txtchequedate" Format="yyyy-MM-dd"></asp:CalendarExtender>
</td>
</tr>
<tr>
<td class="td1" title="Cheque No.">Cheque No.:</td>
<td class="td2">
<asp:TextBox ID="txtchequeno" runat="server" CssClass="textbox" Width="90%" ToolTip="Enter Cheque No."></asp:TextBox>
</td>
</tr>
<tr>
<td class="td1" title="Bank Name">Bank Name:</td>
<td class="td2">
<asp:TextBox ID="txtbankname" runat="server" CssClass="textbox" Width="90%" ToolTip="Enter Bank Name"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td1" title="Branch Name">Branch Name:</td>
<td class="td2">
<asp:TextBox ID="txtbranchname" runat="server" CssClass="textbox" Width="90%" ToolTip="Enter Branch Name"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td1">
<asp:Label ID="lbpaymentdate" runat="server"></asp:Label>
</td>
<td class="td2">
<asp:TextBox ID="txtpaymentdate" runat="server" CssClass="textbox" Width="90%" ToolTip="Enter Clearance Date"></asp:TextBox>
<asp:CalendarExtender runat="server" ID="cetxtclearancedate" CssClass="cal_Theme1" PopupPosition="Right" TargetControlID="txtpaymentdate" Format="yyyy-MM-dd"></asp:CalendarExtender>
</td>
</tr>
<tr>
<td class="td1" title="Amount">Amount:</td>
<td class="td2">
<asp:TextBox ID="txtamount" runat="server" CssClass="textbox" Width="90%" ToolTip="Enter Amount"></asp:TextBox>
</td>
</tr>
<tr>
<td class="td2" colspan="2" style="width:100%;text-align:center;background-color:#FFF6C1">
<asp:Panel ID="pnlchequeimage" runat="server" Visible="false">
<p style="padding-top:5px">Upload a cheque image to <a href="http://www.tinypic.com" target="_blank">TinyPic.com</a> & paste the image url in the textbox below.</p>
<asp:TextBox ID="txtchequeimage" CssClass="textbox" Width="60%" runat="server"></asp:TextBox>
<br />
<br />
</asp:Panel>
</td>
</tr>
<tr>
<td class="td1" colspan="2" style="width:100%;text-align:center;padding-bottom:10px;padding-top:10px;border-bottom-left-radius:10px;border-bottom-right-radius:10px">
<asp:Button ID="btnmakepayment" runat="server" CssClass="button" Text="Make Payment" OnClientClick="return validate()" ToolTip="Make Payment" Width="120px" />
</td>
</tr>
</table>
Javascript:
<script type="text/javascript">
function validate() {
if (document.getElementById("<%=rblparticulartype.ClientID%>").value == "Other") {
if (document.getElementById("<%=txtotherparticulartype.ClientID%>").value=="") {
alert("Please enter details");
document.getElementById("<%=txtotherparticulartype.ClientID%>").focus();
return false;
}
}
}
</script>
<br/>
我想检查一下,如果选择了单选按钮“其他”,那么提交时文本框“txtotherparticulartype”不为空
但是如果条件不进入Radiobutton的循环
请帮忙!!!
【问题讨论】:
-
发布渲染的 HTML 和脚本(查看源代码)
标签: javascript asp.net radio-button radiobuttonlist