0
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防止SharePoint 2010中列出新形式的默認:如果條件是假,則使用jQuery
<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;
}
});
我用所有三個選項(一個接一個也),以防止提交行動,但沒有結果。
我做到了,在函數中添加了e,但仍然無效。這是SharePoint列表表單,因此它會自動創建該ID。因爲它是SharePoint表單,所以我無法更改attrib的值。 –
你的按鈕有點不對勁,你不應該有一個onclick!既然你在jquery – CME64
中添加處理器,雙方都沒有onclick屬性設置,本地的會獲勝! '' – CME64