Can not submit form react-bootstrap
I've been successful with reactstrap using the following snippet:
<Button onClick={this.onSubmit}>Login</Button>
There is one thing missing, I think.
In gotEmail
, there should be a preventDefault
, so if the user press 'enter', the page won't reload:
gotEmail(event){
event.preventDefault();
// code you want to do
}
FormGroup
does not provide on submit event. You can wrap it with form
element and attach event handler to it:
<form onSubmit={this.gotEmail}>
<FormGroup role="form">
<FormControl type="text" className="form-control"/>
<Button className="btn btn-primary btn-large centerButton" type="submit">Send</Button>
</FormGroup>
</form>
As of version 0.30.2, you can wrap it in a <Form>
, which supports the onSubmit property:
<Form onSubmit={this.gotEmail}>
<FormGroup role="form">
<FormControl type="text" className="form-control"/>
<Button className="btn btn-primary btn-large centerButton"
type="submit">Send</Button>
</FormGroup>
</Form>