Wrapping the handler that sets the text of ``$error`` with an if block checking ``if ($error.length > 0)`` looks strange. Consider adding a comment explaining why the check is needed. Coupling the ``fail`` handler to existing DOM state seems like the wrong solution to the problem.