问题描述
您好,我现在有一个带有2个复选框和一个按钮的表单,我需要做的是,如果用户在我们选中任何可用复选框的情况下单击按钮,我想显示自定义警告,说选择一个 ..如果选择了一个,我不想显示警报...
为此,我使用了以下
http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs / [^ ]
进行了一些更改,如下所示
Hi all I am having a form with 2 check-boxes and a button what I need to do is if the user clicks on a button with our checking any check-box available, I would like to show custom alert saying select one.. If one is selected I don''t want to show the alert...
for this I used the following
http://www.abeautifulsite.net/blog/2008/12/jquery-alert-dialogs/[^]
with some changes as follows
<script type="text/javascript">
$(document).ready(function () {
var atLeastOneIsChecked = $('#checkArray :checkbox:checked').length > 0;
if (atLeastOneIsChecked == 0) {
$("#alert_button").click(function () {
jAlert('This is a custom alert box', 'Alert Dialog');
});
}
});
</script>
<form id="form1" runat="server">
<fieldset id="checkArray">
<input type="checkbox" name="chk[]" value="Apples" />
<input type="checkbox" name="chk[]" value="Bananas" />
</fieldset>
<p>
<input id="alert_button" type="button" value="Show Alert" />
</p>
</form>
但是我对这两种情况都保持警惕,任何人都可以帮助我..
But I am getting alert on both the case can any one help me..
推荐答案
<form id="form1" runat="server">
<fieldset id="checkArray">
<input type="checkbox" name="chk[]" value="Apples" />
<input type="checkbox" name="chk[]" value="Bananas" />
</fieldset>
<p>
<input id="alert_button" type="button" value="Show Alert" />
</p>
</form>
但是我对这两种情况都保持警惕,任何人都可以帮助我..
But I am getting alert on both the case can any one help me..
这篇关于使用Jquery显示自定义警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!