I am creating Materialize Form with React js, to ensure fields are not empty I am using materialize class="validate" property. Even I used required="" and aria-required="true" but while clicking on Submit button empty fields are not getting validate. I dont know why.
Please help me on this..
class ContactForm extends Component {
render() {
return (
<div>
<form onSubmit={this.handleSubmit}>
<div className="input-field col s12 l10">
<i className="material-icons prefix">text_format</i>
<input type="text" id="name" ref="Name" class="validate" required="" aria-required="true"></input>
<label htmlFor="name">Your Name</label>
</div>
<div className="input-field col s12 l10">
<i className="material-icons prefix">phone</i>
<input type="number" id="phone" ref="MobileNo" class="validate" required="" aria-required="true"></input>
<label htmlFor="phone">Mobile No.</label>
</div>
<div className="input-field col s12 l10">
<i className="material-icons prefix">email</i>
<input type="email" id="email" ref="EmailId" class="validate" required="" aria-required="true"></input>
<label htmlFor="email">Your Email</label>
</div>
<div className="center">
<button className="btn" type="submit" >Submit</button>
</div>
</form>
</div>
);
}
}
export default ContactUsForm;