We have 2 page layouts (i.e. PageLayout A, and PageLayout B) PageLayout A require field "customername" but not require "productname" PageLayout B require field "productname" but not require "customername"

How can we accomplish this feature because if we set require fields for both fields, we have to input the value in every page layouts?

Best Regards,


Using PreSaveAction function could be a solution. (Right before item is submitted to server, SharePoint checks for a function called PreSaveAction and if it exists, it sends item to server only if that function returns true.

You would know which layout is loaded within document.location.href string property.

var field_productname = document.querySelector('[title="productname"]').value;
var currURL = document.location.href;
if(field_productname == '' && currURL.indexOf('PageLayoutA') == -1) {
    // Set error message
    return false;
    return true;

Thanks everyone.

It turns out that we can set the content type per page layout which mean we can specific fields for each content type.



  • Yes, content types are the way to go for your requirements. You should mark your answer as the answer so it shows up as the first answer when other users come to this page.
    – Joe McShea
    Feb 19 '19 at 14:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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