In the code I want to have a required attribute to make the field mandatory . But its not working.. Any simple way in react for this validation?
<label htmlFor="name">Name</label>
<input type="text" className="form-control"
id="name" placeholder="Enter name" required/>
Try to add form and button tags:
<form onSubmit={handler}>
<input type="text" id="name" placeholder="Enter name" required />
<button type="submit" />
</form
If this doesn't work, try replacing required with required="required"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With