Updated JS to fix a bug when trying to validate the form