Below is the snapshopt of the form which i am rendering, everything works fine except that i am not able to make form fields compulsory.I am rendering this form by means of react component.
Code:-
return <div className="panel alignment div-background" id="new-trade-form">
{this.props.store.newTradeRender}
<div className="panel panel-default">
<div className="panel-heading center-align" ><strong>New Trade</strong></div>
</div>
<div className="panel-body">
<fieldset>
<form name="myForm" id="newForm" ref="newForm" data-toggle="validator" >
Trade Date:
<div className='input-group date'>
<input type='date' className="form-control" id="date" required />
<span className="input-group-addon">
<span className="glyphicon glyphicon-calendar"></span>
</span>
</div>
<br />
<div className="form-group">
Commodity:
<select className="form-control" id="commodity" ref="commodity" required>
<option disabled selected value=""> -- select a commodity -- </option>
{commodity}
</select>
</div>
Side:
<input type="radio" id="side" name="side" value="BUY" ref="side" />Buy
<input type="radio" id="side" name="side" value="SELL" ref="side" />Sell
<br />
<br />
<div className="form-group">
Counterparty:
<select className="form-control" id="counterparty" ref="counterparty" required>
<option disabled selected value=""> -- select a counter party -- </option>
{counterParty}
</select>
</div>
<br />
<div className="form-group">
Price($):<input id="price" name="price" type="number" step="any" className="form-control" ref="price" required />
</div>
<br />
<div className="form-group">
Quantity(MT):<input id="qty" name="qty" type="number" step="any" className="form-control" ref="qty" required />
</div>
<br />
<div className="form-group">
Location:
<select className="form-control" id="location" ref="location" required>
<option disabled selected value=""> -- select a location -- </option>
{location}
</select>
</div>
<br />
<button type='submit' className="btn btn-css btn-size" onClick={this.onSave} >SAVE</button>
</form>
</fieldset>
</div>
</div>
Note i am not getting any errors and everything works fine.
Below is the snapshot of the form:-
` and `` do not use or need a closing slash and never have. – Rob Mar 28 '18 at 11:27