Improve guard in form-validate error handler

Fix #1370