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
Rakesh SamalRakesh Samal 

New to javascript. Help me for the code.

I created a vfp "Vendor reg form".
Fields: Vendor Company Name(text),  Vendor Contact Person(text),
Amount per event(text). city(text),  country(text).
3 buttons:  Send Email, Rest,  Generate PDF
(on press of send email button, mail to CEO).

validation for above case:
1. Vendor name is mandatory
2. If amount is blank, he cannot click on "SEND EMAIL" button
3. Generate pdf not possible when "city" and "country" not mentioned.
4. use renderAS attribute to generate pdf. But onclick button.

Kindly help me anyone. Below is my code. I am stuck on send email and generate pdf.

visualforce page:
<apex:page controller="VendorRegistrationClass" >
    <script>
    
    function validate()
    {
         if(document.getElementById('{!$component.frm.vendorRegFrm.vendorDetails.vendorName}').value=='')  
            {
                alert('Vendor Name is Mandatory');
            }
    }
    
    </script>
    
    <apex:form id="frm">
        <apex:pageBlock title="Vendor Registration Form" id="vendorRegFrm">
            <apex:pageBlockSection columns="2" id="vendorDetails">
                <apex:outputLabel >Vendor Company Name:</apex:outputLabel>
                <apex:inputText value="{!VendorCompanyName}" id="vendorName"/>
                <apex:outputLabel >Vendor Contact Person:</apex:outputLabel>
                <apex:inputText value="{!VendorContactPerson}" id="vendorContact"/>
                <apex:outputLabel >Amount Per Event:</apex:outputLabel>
                <apex:inputText value="{!AmountPerEvent}" id="amount" onkeyup=""/>
                <apex:outputLabel >City:</apex:outputLabel>
                <apex:inputText value="{!City}" id="city"/>
                <apex:outputLabel >Country:</apex:outputLabel>
                <apex:inputText value="{!Country}" id="country"/>
                <apex:commandButton value="Send Email" action="{!SendEmail}" onclick="validate()" id="email" reRender="vendorName"/>
                <apex:commandButton value="Reset" action="{!Reset}"/> 
                <apex:commandButton value="Generate PDF" action="{!GeneratePDF}"/>
                <apex:outputLabel >{!message}</apex:outputLabel>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Apex class:
public class VendorRegistrationClass {
    public string VendorCompanyName {get;set;}
    public string VendorContactPerson {get;set;}
    public string AmountPerEvent {get;set;}
    public string City {get;set;}
    public string Country {get;set;}
    public boolean email {get;set;}
    public string message {get;set;}
    
    
    public PageReference Reset()
    {
        PageReference newpage = new PageReference(System.currentPageReference().getURL());
        newpage.getParameters().clear();
        newpage.setRedirect(true);
        return newpage;
    }
}




 
Jonye KeeJonye Kee