now adds 'error' class to an invalid element