未选择单选按钮时显示警报

编程入门 行业动态 更新时间:2024-10-13 14:23:09
本文介绍了未选择单选按钮时显示警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

你好朋友我有单选按钮。当我取消选中单选按钮时,警报会响起,但即使我选中了单选按钮也会发出警报 我的代码是

hello friends i m having radio button. When i uncheck radio button, alert will come but for me alert coming even i checked radio button my code is

<script type="text/javascript"> function as() { <code>//if(!document.getElementById("RadioBtn").checked) </code>{ alert("check the field"); } } </script>

和div

and in div

<asp:RadioButtonList ID="RadioBtn" runat="server" RepeatDirection="Horizontal"> <asp:ListItem>Male</asp:ListItem> <asp:ListItem>Female</asp:ListItem> </asp:RadioButtonList> <asp:button Onclientclick="as()" runat="server">

i想要使用验证使用javascript。

i want to use validation using javascript.

推荐答案

在哪里将函数分配给radiobuttonlist的事件? 此外我不认为RadionButtonList有已检查属性甚至属性。 尝试使用此JQuery代码在选择时发出警报(因为一旦您在同一个RadioButtonList中选择了其他单选按钮,就会自动取消选择): Where you are assigning the function to radiobuttonlist's event? Further I don't think RadionButtonList has a "Checked" property or even an attribute. Try this JQuery code to get an alert when you select (since deselect is done automatically once you select some other radio button in the same RadioButtonList):

(document).ready(function(){ (document).ready(function() {

( #RadioBtn输入[type ='radio'])。click(function(){alert('hi');}); }); ("#RadioBtn input[type='radio']").click(function() { alert('hi'); }); });

更多推荐

未选择单选按钮时显示警报

本文发布于:2023-11-27 22:04:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639770.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   单选   按钮

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!