3 Answers
3

Add the <apex:pageMessages/> tag to your page. (This is the container that displays any error messages if present)

Surround your DML call with try {} catch(DMLException e) {} (When you catch the exception you won't get redirected to the error pages, but salesforce will automatically create a "PageMessage" for the validation failure.

This will print the first DML error that statement caused which is usually what you want.
You can also try e.getMessage() but this will show additional information (like Update failed. First exception on row 0 with id 001L000000QgmomIAB; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION etc.) which is not user friendly. The advantage of e.getDmlMessage is that it prints only the validation rule when the error is caused by validation rule.