Sharepoint 2010验证公式 [英] Sharepoint 2010 validation formula
问题描述
想知道如何编写验证公式
Like to know how can I write a validation formula
如果我有一个复选框字段= Class,该复选框将是"A","B","其他"
If I have a checkbox field = Class, and the checkbox will be "A", "B","Others"
并且我想要检查其他,然后是字段调用"其他类"。 (这是一个文本字段)不能为空。
and I want if Others is checked, then the field call "Others Class" (this is a text field) cannot be blank.
如何写一个验证来检查这个? thx
How do write a validation to check on this? thx
推荐答案
您好
对于Sharepoint 2010,请在内容编辑器webpart内的脚本下面调用。这里的功能是"Presaveaction"。在"保存"时调用单击按钮。
For Sharepoint 2010 call below script inside content editor webpart. Here function "Presaveaction" is called when "Save" button is clicked.
<script type="text/javascript">
function PreSaveAction()
{
//Pass CheckBoxID of Others & TextBoxID of OthersClass
var checkBoxClass = document.getElementById("ctl00_m_g_52024de5_b38d_4693_bd9a_b0b57b8fe384_ctl00_ctl05_ctl12_ctl00_ctl00_ctl04_ctl00_ctl02");
var OthersClass = document.getElementById("ctl00_m_g_52024de5_b38d_4693_bd9a_b0b57b8fe384_ctl00_ctl05_ctl13_ctl00_ctl00_ctl04_ctl00_ctl00_TextField").value;
//Check if Others is selected than validate OthersClass Text Box
if (checkBoxClass.checked == true && OthersClass == "")
{
alert("Please provide your input to 'Others Class'");
return false;
}
return true;
}
</script>
注意:您需要传递"其他"的checkboxID。 &安培; OthersClass的TextBoxID。
Note: You need to pass checkboxID of "Others" & TextBoxID of OthersClass .
要获取ID,请右键点击Newform - > ViewSource从此处查找您的ID
To get ID, Right click on Newform-->ViewSource from here look for your ID
谢谢
这篇关于Sharepoint 2010验证公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!