当mvc3 rezor视图中存在复选框数组时,如何限制选择两个或更多复选框 [英] How to restrict selecting two or more checkboxes when array of checkboxes present in mvc3 rezor view

查看:55
本文介绍了当mvc3 rezor视图中存在复选框数组时,如何限制选择两个或更多复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hii给大家,

最后2周我开始学习MVC3,我开始使用MVC3 Razor视图准备注册页面,这里用户需要选择intrest的区域,为此我放置了4个复选框。我的要求是我需要限制用户在任何时间点只选择一个复选框,我怎样才能实现这个....还试着告诉我与mvc3 Razor中的复选框相关的可能事件





谢谢

Ramu

解决方案

检查: http://www.nwa4.com/blog/ asp.net-mvc-multiple-checkboxes-validation-and-handling-using-c-sharp [ ^ ]


仍然如果你想选中复选框,然后在jsFiddle上结帐样本

http://jsfiddle.net/vijaypatel/KtPsQ/ [ ^ ]



使用以下功能限制用户进行单项选择



 <   input     type   = 复选框    id   =  chk1    class   =  chk   名称  =  chk1    /  > 复选框1 
< span class =code-keyword>< input type = 复选框 id = chk2 class = chk 名称 = chk2 / > 复选框2
< input type = 复选框 id = chk3 class = chk 名称 = chk3 / > 复选框3
< 输入 type = 复选框 id = chk4 class = chk name = chk4 / > 复选框4





 


' 输入。 chk')。change(function(){
if


Hii to everyone,
for the last 2weeks i started learning MVC3,i started preparing a registration page using MVC3 Razor view,here user need to select area of intrest, for this i placed 4 checkboxes.My requirement is i need to restrict the user to select only one checkbox at any point of time, how can i achieve this....also try to tell me the possible events associated with checkbox in mvc3 Razor


Thanks
Ramu

解决方案

Check this: http://www.nwa4.com/blog/asp.net-mvc-multiple-checkboxes-validation-and-handling-using-c-sharp[^]


And still if you want to go with checkboxes then checkout sample on jsFiddle
http://jsfiddle.net/vijaypatel/KtPsQ/[^]

Use below function to restrict user on single selection

<input type="checkbox" id="chk1" class="chk" name="chk1" /> checkbox 1
<input type="checkbox" id="chk2" class="chk" name="chk2" /> checkbox 2
<input type="checkbox" id="chk3" class="chk" name="chk3" /> checkbox 3
<input type="checkbox" id="chk4" class="chk" name="chk4" /> checkbox 4




('input.chk').change(function(){ if(


这篇关于当mvc3 rezor视图中存在复选框数组时,如何限制选择两个或更多复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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