Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/445.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如果条件为false,则使用jquery防止SharePoint 2010中的默认列表新表单_Javascript_Jquery_Sharepoint_Sharepoint 2010 - Fatal编程技术网

Javascript 如果条件为false,则使用jquery防止SharePoint 2010中的默认列表新表单

Javascript 如果条件为false,则使用jquery防止SharePoint 2010中的默认列表新表单,javascript,jquery,sharepoint,sharepoint-2010,Javascript,Jquery,Sharepoint,Sharepoint 2010,HTML: 同样,有10个TD元素 保存按钮: <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&g

HTML:

同样,有10个TD元素

保存按钮:

<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>

我使用了所有三个选项,并且一个接一个地阻止提交操作,但没有结果

必须在函数中传递事件,否则变量e将未定义

<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; 
       }
});
如果不起作用,请检查html代码,并在属性值(例如attrib=value)周围添加双引号,以确保语法正确


我得问一下,长id是怎么回事?

我这样做了,在函数中添加了e,但仍然不起作用。这是SharePoint列表表单,因此它会自动创建该id。由于它是SharePoint表单,我无法更改属性的值。dude您的按钮有问题,您不应该在其中单击一次!由于您在jqueryno onclick属性设置中从两侧添加了处理程序,因此本地处理程序将获胜!是的,只要从按钮本身删除onclick,jquery就会添加处理它的函数,检查我在回答中添加的fiddle,不要忘记在$document中添加所有jquery代码;不,它没有解决。我检查了你们的小提琴,你们把按钮本身的onlick功能去掉了。但由于这是SharePoint,我不能这样做。。。当我尝试这样的$ctl00_m_g_69fc6715_3136_4421_a83a_06892e860a7a_savebutton2_ctl00_diidIOSaveItem.attr'onclick',.unbind'click';这两个功能都停止工作。
<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; 
       }
});
$("#ctl00_m_g_69fc6715_3136_4421_a83a_06892e860a7a_savebutton2_ctl00_diidIOSaveItem").click(function(e) {

    if($('.ms-RadioText input:checked').length!=3)
       {
           alert("You have to select any 3 options");
            e.preventDefault();
            e.returnvalue=false // for IE only
            return false; 
       }
});