diff --git a/src/pages/settings/AddSecondaryLoginPage.js b/src/pages/settings/AddSecondaryLoginPage.js index 3731aa043e3c..69b83bff888d 100755 --- a/src/pages/settings/AddSecondaryLoginPage.js +++ b/src/pages/settings/AddSecondaryLoginPage.js @@ -71,6 +71,7 @@ class AddSecondaryLoginPage extends Component { }; this.formType = props.route.params.type; this.submitForm = this.submitForm.bind(this); + this.onSecondaryLoginChange = this.onSecondaryLoginChange.bind(this); this.validateForm = this.validateForm.bind(this); this.phoneNumberInputRef = null; @@ -80,6 +81,15 @@ class AddSecondaryLoginPage extends Component { Onyx.merge(ONYXKEYS.USER, {error: ''}); } + onSecondaryLoginChange(login) { + if (this.formType === CONST.LOGIN_TYPE.EMAIL) { + this.setState({login}); + } else if (this.formType === CONST.LOGIN_TYPE.PHONE + && (CONST.REGEX.DIGITS_AND_PLUS.test(login) || login === '')) { + this.setState({login}); + } + } + /** * Add a secondary login to a user's account */ @@ -135,7 +145,7 @@ class AddSecondaryLoginPage extends Component { ref={el => this.phoneNumberInputRef = el} style={styles.textInput} value={this.state.login} - onChangeText={login => this.setState({login})} + onChangeText={this.onSecondaryLoginChange} keyboardType={this.formType === CONST.LOGIN_TYPE.PHONE ? CONST.KEYBOARD_TYPE.PHONE_PAD : undefined} returnKeyType="done"