If an input field contains invalid data, display a message in Javascript