function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sanjusfdcsanjusfdc 

Display Pop-up messege in command button based on inputText.

There are two inputText Mobile and Email.
When i fill only Mobile inputText one popup message should be display and if i fill only email inputText another popup messege should display.
Best Answer chosen by sanjusfdc
Prashant Pandey07Prashant Pandey07
You may try something like this to solve the problem. 
 
<apex:page standardController="Account" extensions="AccountExtensionsforcontact" id="pg">

<script type="text/javascript">

function displaymessage()
{
   var a1 = document.getElementById('pg:frm:pb:pbs:a1').value;  //get all the id for pageblock/section/forms etc
alert(''+a1);
if(a1==''){

alert("Remember to Submit changes that you have made!");
}
}

</script>

<apex:form id="frm">
    <apex:pageBlock title="Account Info" id="pb">
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" onclick="displaymessage(); return false"  />//popup message
            <apex:commandButton value="Go to Contact" action="{!gotocontract}"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbs">
        <apex:outputField value="{!Account.name}"/>
        <apex:inputField value="{!Account.phone}" id="a1" />
         <apex:inputField value="{!Account.recordtypeid}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Class
 
public class AccountExtensionsforcontact {
   public String ids;
   public String id1;
   
    public Account acc {get;set;}
  public Contact  con {get;set;}
     public AccountExtensionsforcontact(ApexPages.StandardController controller) {
  ids=Apexpages.currentPage().getParameters().get('id'); 
   
  acc=[Select id,name,phone from account where id=:ids];
     }
     
     public PageReference gotocontract(){

     PageReference redirect = new PageReference('/apex/Coutacttcreate?id='+ids);
 
    return redirect;
 
     }
         
     

}

--
Thanks,
Prashant


 

All Answers

Prashant Pandey07Prashant Pandey07
You may try something like this to solve the problem. 
 
<apex:page standardController="Account" extensions="AccountExtensionsforcontact" id="pg">

<script type="text/javascript">

function displaymessage()
{
   var a1 = document.getElementById('pg:frm:pb:pbs:a1').value;  //get all the id for pageblock/section/forms etc
alert(''+a1);
if(a1==''){

alert("Remember to Submit changes that you have made!");
}
}

</script>

<apex:form id="frm">
    <apex:pageBlock title="Account Info" id="pb">
        <apex:pageBlockButtons >
            <apex:commandButton value="Save" action="{!save}" onclick="displaymessage(); return false"  />//popup message
            <apex:commandButton value="Go to Contact" action="{!gotocontract}"/>
                </apex:pageBlockButtons>
                <apex:pageBlockSection id="pbs">
        <apex:outputField value="{!Account.name}"/>
        <apex:inputField value="{!Account.phone}" id="a1" />
         <apex:inputField value="{!Account.recordtypeid}" />
        </apex:pageBlockSection>
    </apex:pageBlock>
</apex:form>
</apex:page>

Class
 
public class AccountExtensionsforcontact {
   public String ids;
   public String id1;
   
    public Account acc {get;set;}
  public Contact  con {get;set;}
     public AccountExtensionsforcontact(ApexPages.StandardController controller) {
  ids=Apexpages.currentPage().getParameters().get('id'); 
   
  acc=[Select id,name,phone from account where id=:ids];
     }
     
     public PageReference gotocontract(){

     PageReference redirect = new PageReference('/apex/Coutacttcreate?id='+ids);
 
    return redirect;
 
     }
         
     

}

--
Thanks,
Prashant


 
This was selected as the best answer
sanjusfdcsanjusfdc
Thanks Prashant
Prashant Pandey07Prashant Pandey07
Hi Sanjusfdc,

Please mark this as the best answer to update the unsolve to solved and help the community grow.

--
Thanks,
Prashant