I've created VF page and I've created custom button, I need to restrict the button for some profiles, How can I show error message when other profile users clicks on the button
===
<apex:page controller="LeadAssignController">
<apex:form id="frm">
<script>
function checkboxuse(tag) {
var menus = document.getElementsByClassName("Teststyle");
if (tag.checked == true) {
for (var i = menus.length - 1; i >= 0; i--)
{
menus[i].checked = false;
}
tag.checked = true;
}
else {
for (var i = menus.length - 1; i >= 0; i--)
{
menus[i].checked = true;
}
}
}
</script>
<apex:pageBlock >
<apex:pageBlockSection columns="1" rendered="{!IF(sobjectName== 'Lead', true, false)}">
<apex:outputField value="{!ldRecord.Name}"/>
<apex:outputField value="{!ldRecord.Implementer_Assignment__r.name}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" rendered="{!IF(sobjectName== 'Lead', true, false)}">
<apex:outputField value="{!ldRecord.Region__r.name}"/>
<apex:outputField value="{!ldRecord.Area__r.name}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" rendered="{!IF(sobjectName== 'Lead', false, true)}">
<apex:outputField value="{!OppRecord.Name}"/>
<apex:outputField value="{!OppRecord.ImplementerContact_r.name}"/>
</apex:pageBlockSection>
<apex:pageBlockSection columns="1" rendered="{!IF(sobjectName== 'Lead', false, true)}">
<apex:outputField value="{!OppRecord.Region_EI__r.name}"/>
<apex:outputField value="{!OppRecord.Segment__r.name}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock >
<apex:pageBlockSection columns="1">
<apex:pageBlockTable value="{!SubContractorList}" var="subC">
<apex:column >
<apex:inputCheckbox value="{!subC.selected}" id="tst" styleClass="Teststyle" onchange="return checkboxuse(this)"/>
</apex:column>
<apex:column value="{!subC.sc.name}"/>
<apex:column value="{!subC.sc.SubContractor_AccountID_EI__r.name}"/>
<apex:column value="{!subC.sc.Primary_Contractor_EI__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton action="{!saveSubcontractor}" value="Select" rendered="{!SubContractorList!=null}"/>
<apex:commandButton action="{!cancel}" value="Cancel" />
</apex:pageBlockButtons>