how to validation error messages render automatically when i enter the required field value in snip

When i click on save button without enter any data, i am getting some error messages like " field is required" whatever i have written in my snippet code. my requirement is like ’ i want to clear the error message  when i click required field or when i enter the data on that field. can any one give sample snippet for this requirement.