login & register form are now being submitted when pressing the 'enter' key
This commit is contained in:
@@ -52,8 +52,11 @@ var Login = React.createClass({
|
||||
renderErrorMessage: function(message){
|
||||
return (<div className='error-message'>{message}</div>)
|
||||
},
|
||||
doLogin: function(e) {
|
||||
|
||||
onLoginClick: function(e) {
|
||||
this.doLogin();
|
||||
e.preventDefault();
|
||||
},
|
||||
doLogin: function() {
|
||||
if(this.validate()) {
|
||||
var loginInfo = new LoginModel({
|
||||
email: this.state.email,
|
||||
@@ -61,10 +64,8 @@ var Login = React.createClass({
|
||||
});
|
||||
|
||||
UserActions.userLogin(loginInfo);
|
||||
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
renderLoginFailure: function() {
|
||||
|
||||
@@ -75,6 +76,12 @@ var Login = React.createClass({
|
||||
|
||||
return (<div></div>)
|
||||
},
|
||||
onKeyPress: function(e) {
|
||||
var enterKeyCode = 13;
|
||||
if(e.which == enterKeyCode) {
|
||||
this.doLogin();
|
||||
}
|
||||
},
|
||||
render : function() {
|
||||
return (<div>
|
||||
<div className="col-md-6">
|
||||
@@ -86,18 +93,18 @@ var Login = React.createClass({
|
||||
|
||||
<div className="form-group">
|
||||
<label for="email">Email adresa</label>
|
||||
<input type="email" onChange={this.handleChange('email')} className="form-control" id="email" placeholder="Unesite email"></input>
|
||||
<input type="email" onKeyPress={this.onKeyPress} onChange={this.handleChange('email')} className="form-control" id="email" placeholder="Unesite email"></input>
|
||||
|
||||
{this.getValidationMessages('email').map(this.renderErrorMessage)}
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<label for="password">Šifra</label>
|
||||
<input type="password" onChange={this.handleChange('password')} className="form-control" id="password" placeholder="Šifra"></input>
|
||||
<input type="password" onKeyPress={this.onKeyPress} onChange={this.handleChange('password')} className="form-control" id="password" placeholder="Šifra"></input>
|
||||
|
||||
{this.getValidationMessages('password').map(this.renderErrorMessage)}
|
||||
</div>
|
||||
<div className="form-group">
|
||||
<button type="button" onClick={this.doLogin} className="btn btn-success">Prijava</button>
|
||||
<button type="button" onClick={this.onLoginClick} className="btn btn-success">Prijava</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user