<input type="text" className="form-control firstname-input" id="firstname" placeholder="John" onInput={(e) => { const input = e.target as HTMLInputElement; input.value = input.value.replace(/[^a-zA-Z ]/g, ''); setFirstName(input.value); }} {...register('firstName', { required: true, })} />