Validate sharepoint People picker control using ECMA Script


var htmlReporting = $("[id$=_usaHrReportingManager_upLevelDiv]");
var pplReportingManager = $("#divEntityData", htmlReporting).attr("description");
 usaReportingManageer = SP.FieldUserValue.fromUser(pplReportingManager);
        if (usaReportingManageer.$2d_1 == undefined) {
            alert("Please Mention Reporting Manager");
            $("[id$=_usaEditHrApprovedBy_upLevelDiv]").focus();
            return false;
        }


Another Approach: Best One

 $("#btnPickUser").click(function (e) {
        var eEntityData = $("div[id='divEntityData']");
        if ($("[id$=_pplPickUser_containerCell]").text().trim().length == 0) {
            alert("Please Enter Resource Name")
        }
        else if (eEntityData.length == 0) {
            alert("Please click on Check Name or Press ctrl+ K ");
        }
   });

Comments

Popular posts from this blog

My Interview Experience

React Checkbox Control SPFx