Validation works on AnguarJS but not JavaScript