<apex:page standardcontroller="Competitor__c" extensions="ctrlCompetitor" language="{!$CurrentPage.parameters.lang}" action="{!init}">
<apex:sectionheader title="{!$ObjectType.Competitor__c.label} Edit" subtitle="{!IF(ISNULL(Competitor__c.name), 'New Competitor',Competitor__c.name)}"/>
function chngPrimComp(cmp,val){
var c;
var flag=0;
if(cmp.checked==false && flag!=0){
alert('{!$Label.msgCantUnchk}');
cmp.checked=true;
flag++;
}
if(cmp.checked==true && flag==0){
ctrlCompetitor.checkFirstPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
if(event.status){
if(result=='false'){
c=confirm('{!$Label.msgPrmryCompCnfrm}');
if(c==true){
flag++;
ctrlCompetitor.checkPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
if(event.status){}
if(event.exception){}
});
}
else if(c==false){
cmp.checked=false;
}
}
}
});
}
}
<apex:pageMessages id="mymsg" />
<apex:form >
<apex:pageblock mode="edit" title="{!$ObjectType.Competitor__c.label} Edit">
<apex:pageblockbuttons >
<apex:commandButton value="Save" action="{!Save}" />
<apex:commandbutton value="Cancel" action="{!Cancel}"/>
</apex:pageblockbuttons>
<apex:outputpanel >
<apex:pageblocksection title="Information" showheader="true" columns="2">
<apex:inputfield id="oppid" value="{!Competitor__c.Opportunity__c}" required="true"/>
<apex:inputfield value="{!Competitor__c.Amount__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitor_Name__c}" required="true"/>
<apex:inputfield id="chkbox" value="{!Competitor__c.Primary_Competitor__c}" required="false" onchange="chngPrimComp(this,this.value);" />
<apex:inputfield value="{!Competitor__c.Competitor_Machine__c}" required="false"/>
<apex:pageblocksectionitem />
<apex:inputfield value="{!Competitor__c.Competitor_Machine_Description__c}" required="false"/>
<apex:pageblocksectionitem />
</apex:pageblocksection>
<apex:pageblocksection title="Competitor Strengths / Weaknesses" showheader="true" columns="2">
<apex:inputfield value="{!Competitor__c.Competitors_Strength__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitors_Weakness__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitive_Situation__c}" required="false"/>
<apex:pageblocksectionitem />
</apex:pageblocksection>
<apex:pageblocksection title="System Information" showheader="true" columns="2">
<apex:inputfield value="{!Competitor__c.Name}" required="true"/>
</apex:pageblocksection>
</apex:outputpanel>
</apex:pageblock>
</apex:form>
<apex:page standardcontroller="Competitor__c" extensions="ctrlCompetitor" language="{!$CurrentPage.parameters.lang}" action="{!init}">
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"/>
<apex:sectionheader title="{!$ObjectType.Competitor__c.label} Edit" subtitle="{!IF(ISNULL(Competitor__c.name), 'New Competitor',Competitor__c.name)}"/>
<script>
function chngPrimComp(cmp,val){
var c;
var flag=0;
if(cmp.checked==false && flag!=0){
alert('{!$Label.msgCantUnchk}');
cmp.checked=true;
flag++;
}
if(cmp.checked==true && flag==0){
ctrlCompetitor.checkFirstPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
if(event.status){
if(result=='false'){
c=confirm('{!$Label.msgPrmryCompCnfrm}');
if(c==true){
flag++;
ctrlCompetitor.checkPrimaryComp('{!$CurrentPage.parameters.retURL}',function(result, event){
if(event.status){}
if(event.exception){}
});
}
else if(c==false){
cmp.checked=false;
}
}
}
});
}
}
</script>
**<apex:pageMessages id="mymsg" />**
<apex:form >
<apex:pageblock mode="edit" title="{!$ObjectType.Competitor__c.label} Edit">
<apex:pageblockbuttons >
<apex:commandButton value="Save" action="{!Save}" />
<apex:commandbutton value="Cancel" action="{!Cancel}"/>
</apex:pageblockbuttons>
<apex:outputpanel >
<apex:pageblocksection title="Information" showheader="true" columns="2">
<apex:inputfield id="oppid" value="{!Competitor__c.Opportunity__c}" required="true"/>
<apex:inputfield value="{!Competitor__c.Amount__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitor_Name__c}" required="true"/>
<apex:inputfield id="chkbox" value="{!Competitor__c.Primary_Competitor__c}" required="false" onchange="chngPrimComp(this,this.value);" />
<apex:inputfield value="{!Competitor__c.Competitor_Machine__c}" required="false"/>
<apex:pageblocksectionitem />
<apex:inputfield value="{!Competitor__c.Competitor_Machine_Description__c}" required="false"/>
<apex:pageblocksectionitem />
</apex:pageblocksection>
<apex:pageblocksection title="Competitor Strengths / Weaknesses" showheader="true" columns="2">
<apex:inputfield value="{!Competitor__c.Competitors_Strength__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitors_Weakness__c}" required="false"/>
<apex:inputfield value="{!Competitor__c.Competitive_Situation__c}" required="false"/>
<apex:pageblocksectionitem />
</apex:pageblocksection>
<apex:pageblocksection title="System Information" showheader="true" columns="2">
<apex:inputfield value="{!Competitor__c.Name}" required="true"/>
</apex:pageblocksection>
</apex:outputpanel>
</apex:pageblock>
</apex:form>
</apex:page>
</apex:page>
================================================================================