Toggle valid and invalid classes on input and outpupt

This PR includes the changes by @JacquesLoubser in #67.