未选择单选按钮时显示警报 [英] display alert when radio button is not selected

查看:97
本文介绍了未选择单选按钮时显示警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



我的代码是

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'); }); });


这篇关于未选择单选按钮时显示警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆