User error message on field entry

Using an Ajax routine, onChange, I edit the field that is entered.
I can use a error message to inform the user.
However I need to reset that field to blank, or zero.

inserting after the message {my_field} = 0; does not reset the field.

How do I prevent the user from continuing with that field value