• Ashok.Force
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

Hi,

   I have  the following Apex Page where the form shouldn't submit if there is any validation error.

 

<apex:page showHeader="false" sidebar="false" standardController="Lead"
    extensions="Beneficiary">


    <h1>NGO membership form</h1>

    <apex:form id="myform" styleClass="standard-form"
        enctype="multipart/form-data">

        <apex:outputText value="Organisation" />
        <apex:inputText value="{!Lead.Company}" label="Organisation"
            required="true" id="organisation" />
        <br></br>
        <apex:outputText value="Email" />
        <apex:inputText value="{!Lead.Email__c}" label="Email" required="true"
            id="email" />
        <br></br>
        <apex:outputText value="LastName" />
        <apex:inputText value="{!Lead.LastName}" label="LastName"
            required="true" id="lastname" />
        <br></br>

        <apex:commandButton value="Submit" onclick="validate()" immediate="false"/>
    </apex:form>


    <script>
function validate()
{

    var a = document.getElementById('{!$Component.myform.lastname}').value;
    if(a == null || a.length == 0)
    {
         alert("Last name is a Mandatory Field");
         return null;
    }

}
</script>

</apex:page>

 

If the lastname is blank. I'm getting the validation error. But the form still submits. How to stop the form submission if there is any validation error?

HI,
   When the lead is converted Account/Contact record created. Also a Portal User account created.

Using that Portal User Account is it possible to edit their own Account / Contact Details from the Portal Site?

I can able to login thru the portal site and once the login is success and I'm calling the page where to show the Account / Contact Details

My Controller code

public MyDetails(ApexPages.StandardController controller)
{
parentId   = controller.getId(); 
        
        contact = (Contact)controller.getRecord(); 
        
        String userName = UserInfo.getUserName();
User activeUser = [Select Email From User where Username = :username limit 1];
String userEmail = activeUser.Email;
        
        
        Contact mycontact = [select Salutation, FirstName, LastName, Phone, MobilePhone from Contact where Contact.email__c = :userEmail] ; 
        
  
       
      contact = mycontact;
        
}

But in the page none of the values are shown in the UI

Hi,

   I have  the following Apex Page where the form shouldn't submit if there is any validation error.

 

<apex:page showHeader="false" sidebar="false" standardController="Lead"
    extensions="Beneficiary">


    <h1>NGO membership form</h1>

    <apex:form id="myform" styleClass="standard-form"
        enctype="multipart/form-data">

        <apex:outputText value="Organisation" />
        <apex:inputText value="{!Lead.Company}" label="Organisation"
            required="true" id="organisation" />
        <br></br>
        <apex:outputText value="Email" />
        <apex:inputText value="{!Lead.Email__c}" label="Email" required="true"
            id="email" />
        <br></br>
        <apex:outputText value="LastName" />
        <apex:inputText value="{!Lead.LastName}" label="LastName"
            required="true" id="lastname" />
        <br></br>

        <apex:commandButton value="Submit" onclick="validate()" immediate="false"/>
    </apex:form>


    <script>
function validate()
{

    var a = document.getElementById('{!$Component.myform.lastname}').value;
    if(a == null || a.length == 0)
    {
         alert("Last name is a Mandatory Field");
         return null;
    }

}
</script>

</apex:page>

 

If the lastname is blank. I'm getting the validation error. But the form still submits. How to stop the form submission if there is any validation error?