I have made a form using bootstrap (Form component in reactjs) but when I try to click on submit button even if I do not type any input the form gets submitted. How should I validate my form so that when all the input fields are filled then only form is submitted.
Form component:
class Form extends Component {
render(){
return(
<div>
<div id="center">
<form>
<div className="form-group">
<label htmlFor="firstname">First Name:</label>
<input type="firstname" className="form-control" id="firstname" onChange={this.setFirstName}/>
</div>
<div className="form-group">
<label htmlFor="lastname">Last Name:</label>
<input type="lastname" className="form-control" id="lastname" onChange={this.setLastName}/>
</div>
<div className="form-group">
<label htmlFor="email">Email address:</label>
<input type="email" className="form-control" id="email" onChange={this.setEmailId}/>
</div>
<div className="form-group">
<label htmlFor="bankacc">IBAN:</label>
<div id="deletebank" className="items">
<input type="bankacc" className="form-control" id="bankacc" onChange={this.setIban}/>
<button type="button" className="btn btn-default btn-sm">
<span className="glyphicon glyphicon-trash"></span>
</button>
</div>
</div>
<div className="form-group">
<label htmlFor="bankname">Bank Name:</label>
<input type="bankname" className="form-control" id="bankname" onChange={this.setBankName}/>
</div>
<div className="form-group">
<button type="button" className="btn btn-success" onClick={this.showUser}>Submit</button>
</div>
</form>
</div>
</div>
)}
}
Screenshot: