Control with php-button and error_message

I have a control with some form fields and a button that runs a php script.

within this php script I check some fields :

if( sc_date_empty({limit_date})) {
sc_error_message (“please fill the date field.”);
sc_error_exit();
}

change_data();

the code is not working… there is no message if the field is empty…
sc_error_message (“please fill the date field.”);
sc_error_exit();

what is the right coding to show a message and return to the control without continuing with change_data() ??

Best regards
Uwe

You can just put your field required. and catch the error onvalidatefailleur

hi,
this does not work if you use a new own php button with php code. In this case onValidateevent is ignored…

Thanks Uwe