Monday, 3 September 2012

Few Intresting Tips On Making a Field Mandatory On Visualforce Page


Inspecting the CSS of the salesforce and playing around a bit we can easily make a field look like a required field with the help of below snippet





The validation can be easily handled at the back end and a small code that will be helping is below

if(is error){
ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.Error, 'Error Message.........'));
}
 tag has to be added in the page to display the error to the user.

2 comments:

  1. We have a attribute called "required" where we can set to true to make a field mandatory to enter by User

    ReplyDelete
  2. Say you have inputtext as search criteria or something you want to make it required ?If inputfield then its good approach to use that attribute but for text box a complete native visualforce can be this!

    ReplyDelete

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...