For example when inserting the client (in PHP) validate if age is above 18, before inserting, validate with a condition, and if entering return an error, that in ajax, could do type:
success: function (data) {
alert('Sucesso');
},
error: function (data) {
alert('Ocorreu um erro, verifique a idade informada!');
}