3

How to make both of these fields require information before user submit the form. Often time user doesn't put their email and submit it or they don't put approve or reject.

enter image description here

  • Why can't you use default "required" property of the column? Just mark both of them as Required. – Aakash Maurya Jan 10 at 14:59
  • @AakashMaurya because this is after user submits a form and ask for an approval. I can't make it "required" since it won't let my form to be saved. – user80785 Jan 10 at 15:21
3

You could do it with something like this:

function PreSaveAction()  
{ 
    if (!$("input[id^='UNIX'][id$='ClientPeoplePicker_HiddenInput']").val())
    {
        return false;
    }

    if (!$("input[name^='UNIX'][name$='RadioButtonChoiceField']:checked").val())
    {
        return false;
    }
    return true;
}

You should also include the jQuery to the page in order for this function to work.

Judging by your question I would say that you need this validation on the edit item page, so you can add the script editor web part to the Edit form and paste this function there or use any other option to inject the script to the page.

  • PreSaveAction() is the way to go for sure. Just to add, PreSaveAction() should be used before any other onLoad event for it to work. – lazoDev Jan 10 at 19:30

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.