The SharePoint 2010 List new form has 10 checkboxes. I want to select only 3 (also not less than) of them.
I used jquery for this but when condition is false then form does not stop doing submit action.
HTML:
<TD><SPAN class=ms-RadioText title=One>
<INPUT id=ctl00_m_g_69fc6715_3136_4421_a83a_06892e860a7a_ff21_ctl00_ctl00 type=checkbox name=ctl00$m$g_69fc6715_3136_4421_a83a_06892e860a7a$ff21$ctl00$ctl00></SPAN></TD>
同样有10个TD元素。
保存按钮:
<INPUT accessKey=O id=ctl00_m_g_69fc6715_3136_4421_a83a_06892e860a7a_savebutton2_ctl00_diidIOSaveItem class=ms-ButtonHeightWidth onclick='if (!PreSaveItem()) return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_69fc6715_3136_4421_a83a_06892e860a7a$savebutton2$ctl00$diidIOSaveItem", "", true, "", "", false, true))' value=Save type=button name=ctl00$m$g_69fc6715_3136_4421_a83a_06892e860a7a$savebutton2$ctl00$diidIOSaveItem target="_self" jQuery1372914969010="1">
jquery:
$("#ctl00_m_g_69fc6715_3136_4421_a83a_06892e860a7a_savebutton2_ctl00_diidIOSaveItem").click(function() {
if($('.ms-RadioText input:checked').length!=3) // ms-RadioText is a class
{
alert("You have to select any 3 options");
e.preventDefault();
e.returnvalue=false // for IE only
return false;
}
});
我使用了所有三个选项(也一个一个)来阻止提交操作但没有结果。