How to stop cursor from jumping to the end of input
问题 I have a controlled React input component and I am formatting the input as shown in onChange code. <input type="TEL" id="applicantCellPhone" onChange={this.formatPhone} name="applicant.cellPhone" value={this.state["applicant.cellPhone"]}/> And then my formatPhone function is like this formatPhone(changeEvent) { let val = changeEvent.target.value; let r = /(\D+)/g, first3 = "", next3 = "", last4 = ""; val = val.replace(r, ""); if (val.length > 0) { first3 = val.substr(0, 3); next3 = val.substr