How to make a field required on the edit form. I have this field called "Approver Email" and "approver name". It does not appear on the Default Form since I am using a templet to hide it. I can't set it as required at the site column level because the system will not save the New form without that field completed. is there any way to add code to a script editor to check If those column are empty before saving/submitting it?

  • How many fields you want to make required? Dec 21, 2018 at 15:10
  • I want to make three fields
    – andy
    Dec 26, 2018 at 15:37

2 Answers 2


Sample demo for PreSaveAction, if PreSaveAction return false, your form data won't submit, You could add dynamic error information for required field by jQuery.

<script type="text/javascript" src="https://code.jquery.com/jquery-1.12.4.js"></script>
    <script language="javascript">
        function PreSaveAction() {
            var patt = /^abcd-[0-9]{4}-\w{4}$/;            
            var EmployeeIDValue = $("input[title='EmployeeID']").val();
            //other fields
            var htmlError = "<br/><span role='alert'>EmployeeID must match format abcd-year-xxx1.</span><br/></span></span>";
            if (patt.test(EmployeeIDValue)) {
                return true;
            else {
                return false;

This answer is not using "Pre Save action" but it might be something to consider.

If you are already creating your own forms and hiding certain fields, you could customise the edit form and set up formatting rules instead. Have a button down the bottom called "submit" or similar, but set up rules so that if your 'required' fields aren't completed, this button is hidden or disabled.

Ensure that you include a message to the user so they know what they've missed and can fix it. You can do that by creating a section in the form with the opposite logic. If [required field] is not blank > Hide this control.

See this post for some ideas / steps to get you started: https://support.office.com/en-us/article/add-custom-help-text-to-a-form-template-cd419f95-0743-42cb-92ac-af5a64f16d82#bm5

Add formatting rules: https://support.office.com/en-us/article/add-formatting-rules-c9171387-0061-43cc-9d54-e260a6b8f9a9

It's not code, but it might do what you need.

Hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.