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
ScottPJScottPJ 

Field Level Validation in SalesForce VisualForce

Does anybody know of a way to perform field level validation in VisualForce.   I would like to enter a field value and if there is an invalid entry, I would like to display an error before the page proceeds to the next field. 
JeremyKraybillJeremyKraybill

Search for "validation" in the VF dev guide, there is a whole page on it and it is the first hit that comes up.

 

Jeremy Kraybill

Austin, TX

shillyershillyer

Create the validation rule on the field, and it will execute in the Visualforce page. Check Online Help to build your validation rule.

 

Hope that helps,

Sati

iceberg4uiceberg4u

I find the field level validation provided from Salesforce's side is slow ie. in heavy applications or sites that need to be fast client side javascript validations are the best.

 

 

sellis360sellis360

I added it to the object as suggested but it is not displayed in a user friendly way.  It came up like this...

 

Insert failed. First exception on row 0; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, Sales Rep 2 cannot be the same as Sales Rep 1.: [Sales_Rep_2__c]

An unexpected error has occurred. Your development organization has been notified.

 

How do you make it a message next to the field like on standard objects?