<style> :required:focus:invalid { border: 1px solid #f00; } </style> <input required="" placeholder="number" pattern="\d+" />