Previous answer (Eric A) is definitely untested and should be downvoted for being incorrect. It assumes both Reviewer fields need to be filled out at the same time. Do not waste your time there.
To restate & understand the problem you have 3 users: Creator, Reviewer 1, Reviewer 2.
Creator: submits item and assigns Reviewer 1.
Reviewer 1: approves and assigns Reviewer 2.
Reviewer 2: approves.
1) Workflow Solution:
This is a typical Multi Stage Approval Workflow. Enable Approval, add a copy of the approval workflow with two stages (Reviewer 1 & 2). Capture Reviewer 2 info on custom approval workflow task form & save to the Reviewer 2 field as part of approval workflow. Benefit here is no custom code. List workflow & done. You can even hide the Reviewer 2 field on the EditForm.aspx.
2) JavaScript EditForm.aspx Solution:
If you really wanted to do this via custom code the pseudo code would look like:
0) Get the current user information.
_spPageContextInfo.userLoginName
1) Query the current list item using CSOM or REST to get the current "Reviewer 1" and "Created By" user values (server dataset).
Get Current list item
ListID JS:
_spPageContextInfo.listId
ItemID JS:
var itemId = null;
$.each(window.location.href.split("?")[1].split("&"),
function(i,d){ return d.startsWith("ID") ? (itemId = d.split("=")[1]) : false ; }
);
2) If "Created By User" & "Reviewer 1" in server dataset BOTH have values AND current user is "Reviewer 1" then "Reviewer 2" is a required field.
var reviewer2Required = true;
3) Add validation using a PreSaveAction to enforce that (assumes classic forms).
function PreSaveAction(){
var fieldName = "Reviewer 2", // the name of the field
msg = fieldName + " is a required field"; // the error message
// ensure reviewer 2 is required and that the person field contains a valid person object.
if(reviewer2Required && $("input[type=hidden]", "[title='" + fieldName + "']").val() == "") {
// write a modern validation error to the display
$("[title='" + fieldName + "']")
.parent().next(".ms-metadata")
.text(msg).css("color", "red");
/* alert(msg); // FYI legacy validation error */
return false; // invalidate
}
return true; // validate
}
I hope this helps. Please let us know which direction you