For example, you would test the state of the validation controls before updating a data record with information entered by the user.
If you detect an invalid state, you bypass the update.
You can write this code in separate php file and call via ajax to publish, in my example I use normal way to publish with no ajax.
You can display all validation errors in the validation controls, or all in one place using a Validation controls perform input checking in server code.
When the user submits a page to the server, the validation controls are invoked to check the user input, control by control.
In addition, validation controls allow you to customize how error information is displayed to the user.
Validation controls provide an easy-to-use mechanism for all common types of standard validation—for example, testing for valid dates or values within a range—plus ways to provide custom-written validation.