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
Micky MMicky M 

Get value before saving

Hi all,

Does anyone know if its possible to get the contents of a visualforce input field so i can check it and throw a message to the page if need or just save it if its ok?

all i need to do is when the user created a new record just say is the quantity on this record the same as another quanitity, I cant use a validation rule as there are a list of these objects.

Thanks
asish1989asish1989
If you want to use javascript method then use this
function DisableCtrlKey(id){
       
        var code = document.getElamentById(id).value;
  alert('code'+code);
         
    }
<apex:inputField value="{!contact.Firstname}"/>
              <apex:inputField value="{!contact.LastName}"/>
              <apex:inputField value="{!contact.Email}"/>
              <apex:inputtext value="{!contact.Email}" label="Re-Type Email Id"  id="test"/> 
     <apex:commandButton value="Save" onClick = "DisableCtrlKey('{!Component.test}');" action="{!controllerMethod}"/.>
    
    
  If you want to do in the contrioller then you can directly acess from contact.Email .
  public Contact contact{get;set;}
  String emailvalue = contact.Email;
  System.debug('Printing the value'+emailvalue);