简体   繁体   English

javascript-将表格上的所有字段设为必填

[英]javascript - Make all fields on a form required

I want to be able to loop through all the fields on a form and make them required in a bit of javascript. 我希望能够遍历表单上的所有字段,并在一些JavaScript中使它们成为必需。 I have been able to do a similar thing to make them disabled and have retrieved them all with var controls = Xrm.Page.ui.controls.get(); 我已经能够做类似的事情来禁用它们,并使用var controls = Xrm.Page.ui.controls.get();检索了它们var controls = Xrm.Page.ui.controls.get(); , but I know to set requirement level I need to get the attribute rather than the UI control, how can get get all attributes at once so I can loop through them? ,但是我知道要设置需求级别,我需要获取属性而不是UI控件,如何一次获取所有属性,以便可以遍历它们?

Thanks 谢谢

Copied almost exactly from the CRM SDK : 几乎完全从CRM SDK复制:

function MakeAllAttributesRequired() {
    var attributes = Xrm.Page.data.entity.attributes.get();
    for (var i in attributes) {
        attributes[i].setRequiredLevel("required");
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在提交表单之前要求所有输入字段? - How to make all input fields be required before submitting a form? 直到所有必填字段都填满后,如何使JavaScript警报不运行 - how to make javascript alert not run until all required fields are filled 如何使PHP中需要几个表格字段? - How to make several form fields required in php? 仅在所有必填字段均已填写时才提交表单吗? - Submit form only if all required fields are full? 在 React 中创建一个字段或所有字段 - Make a field or all fields required in React 使用必需的表单字段填充JavaScript数组 - Populate JavaScript Array With Required Form Fields 如何使用JavaScript修复PDF表单中的“必填字段” - How to fix “required fields” in PDF form with Javascript 在动态表单的仅可见部分内,如何使用javascript设置某些必填字段? - Within just the visible parts of a dynamic form, how to make certain fields required using javascript? 在必填字段不为空的情况下,如何使用javascript在表单中创建条件以在单击“提交”按钮时显示消息? - How to make a condition in form using javascript for displaying a message on clicking submit button while required fields are not empty? Javascript 表单提交但未包含所有附加表单字段 - Javascript form submits but not with all appended form fields
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM