自定义列表-根据其他字段的特定值使字段成为必填项 [英] Custom Lists-Making a field mandatory based on a specific value from another field
问题描述
您好专家
我已经在SharePoint上创建了自定义列表,并且有特定要求.下面是一个示例;
I have created a custom list on the SharePoint and I have a specific requirement. Below is an example;
字段A 字段B 栏位C
Field A Field B Field C
值X A B
Value X A B
如果字段A中的值为"X",则我希望用户创建新项目时将字段B和C强制为用户.因此,这是一个条件性必填字段,仅基于另一个字段中的特定值,否则它将继续保持为可选状态.
If the value in field A is 'X', I want to make field B and C as mandatory for the user when he/she creates a new item. So it's a conditional mandatory field only based on a specific value in another field, else it continues to remain as optional.
对此表示感谢.
谢谢,凯图尔
推荐答案
您可以尝试进行列表验证,例如:
=IF(FieldA="ValueX",AND(FieldB<>"",FieldC<>""),TRUE)
您也可以为此使用PreSaveAction函数,这里是示例代码供您参考(您可能需要根据自己的情况更新jQuery选择器字段类型,这里我使用选择字段和文本字段.)
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript">
function PreSaveAction() {
var FieldA =
("select [title ='FieldA']:selected").text(); alert(FieldA); 如果(FieldA =='ValueX'){ var FieldB =
("select[title='FieldA'] :selected").text(); alert(FieldA); if (FieldA == 'ValueX') { var FieldB =
("input [title ='FieldB']"); var FieldC =
("input[title='FieldB']"); var FieldC =
这篇关于自定义列表-根据其他字段的特定值使字段成为必填项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!