Improved AJAX validation