Validate login phone number on blur
This commit is contained in:
parent
cfe19d710b
commit
eafd7e12d0
2 changed files with 20 additions and 6 deletions
|
@ -284,16 +284,22 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
onPhoneNumberChanged: function(phoneNumber) {
|
onPhoneNumberChanged: function(phoneNumber) {
|
||||||
// Validate the phone number entered
|
|
||||||
if (!PHONE_NUMBER_REGEX.test(phoneNumber)) {
|
|
||||||
this.setState({ errorText: _t('The phone number entered looks invalid') });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
phoneNumber: phoneNumber,
|
phoneNumber: phoneNumber,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
onPhoneNumberBlur: function(phoneNumber) {
|
||||||
|
this.setState({
|
||||||
errorText: null,
|
errorText: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Validate the phone number entered
|
||||||
|
if (!PHONE_NUMBER_REGEX.test(phoneNumber)) {
|
||||||
|
this.setState({
|
||||||
|
errorText: _t('The phone number entered looks invalid'),
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onServerConfigChange: function(config) {
|
onServerConfigChange: function(config) {
|
||||||
|
@ -648,6 +654,7 @@ module.exports = React.createClass({
|
||||||
onUsernameBlur={this.onUsernameBlur}
|
onUsernameBlur={this.onUsernameBlur}
|
||||||
onPhoneCountryChanged={this.onPhoneCountryChanged}
|
onPhoneCountryChanged={this.onPhoneCountryChanged}
|
||||||
onPhoneNumberChanged={this.onPhoneNumberChanged}
|
onPhoneNumberChanged={this.onPhoneNumberChanged}
|
||||||
|
onPhoneNumberBlur={this.onPhoneNumberBlur}
|
||||||
onForgotPasswordClick={this.props.onForgotPasswordClick}
|
onForgotPasswordClick={this.props.onForgotPasswordClick}
|
||||||
loginIncorrect={this.state.loginIncorrect}
|
loginIncorrect={this.state.loginIncorrect}
|
||||||
hsUrl={this.state.enteredHomeserverUrl}
|
hsUrl={this.state.enteredHomeserverUrl}
|
||||||
|
|
|
@ -35,6 +35,7 @@ class PasswordLogin extends React.Component {
|
||||||
onPasswordChanged: function() {},
|
onPasswordChanged: function() {},
|
||||||
onPhoneCountryChanged: function() {},
|
onPhoneCountryChanged: function() {},
|
||||||
onPhoneNumberChanged: function() {},
|
onPhoneNumberChanged: function() {},
|
||||||
|
onPhoneNumberBlur: function() {},
|
||||||
initialUsername: "",
|
initialUsername: "",
|
||||||
initialPhoneCountry: "",
|
initialPhoneCountry: "",
|
||||||
initialPhoneNumber: "",
|
initialPhoneNumber: "",
|
||||||
|
@ -60,6 +61,7 @@ class PasswordLogin extends React.Component {
|
||||||
this.onLoginTypeChange = this.onLoginTypeChange.bind(this);
|
this.onLoginTypeChange = this.onLoginTypeChange.bind(this);
|
||||||
this.onPhoneCountryChanged = this.onPhoneCountryChanged.bind(this);
|
this.onPhoneCountryChanged = this.onPhoneCountryChanged.bind(this);
|
||||||
this.onPhoneNumberChanged = this.onPhoneNumberChanged.bind(this);
|
this.onPhoneNumberChanged = this.onPhoneNumberChanged.bind(this);
|
||||||
|
this.onPhoneNumberBlur = this.onPhoneNumberBlur.bind(this);
|
||||||
this.onPasswordChanged = this.onPasswordChanged.bind(this);
|
this.onPasswordChanged = this.onPasswordChanged.bind(this);
|
||||||
this.isLoginEmpty = this.isLoginEmpty.bind(this);
|
this.isLoginEmpty = this.isLoginEmpty.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -153,6 +155,10 @@ class PasswordLogin extends React.Component {
|
||||||
this.props.onPhoneNumberChanged(ev.target.value);
|
this.props.onPhoneNumberChanged(ev.target.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onPhoneNumberBlur(ev) {
|
||||||
|
this.props.onPhoneNumberBlur(ev.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
onPasswordChanged(ev) {
|
onPasswordChanged(ev) {
|
||||||
this.setState({password: ev.target.value});
|
this.setState({password: ev.target.value});
|
||||||
this.props.onPasswordChanged(ev.target.value);
|
this.props.onPasswordChanged(ev.target.value);
|
||||||
|
@ -214,6 +220,7 @@ class PasswordLogin extends React.Component {
|
||||||
type="text"
|
type="text"
|
||||||
name="phoneNumber"
|
name="phoneNumber"
|
||||||
onChange={this.onPhoneNumberChanged}
|
onChange={this.onPhoneNumberChanged}
|
||||||
|
onBlur={this.onPhoneNumberBlur}
|
||||||
placeholder={_t("Mobile phone number")}
|
placeholder={_t("Mobile phone number")}
|
||||||
value={this.state.phoneNumber}
|
value={this.state.phoneNumber}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
|
Loading…
Reference in a new issue