Bootstrap Form Validation
Bootstrap provides built-in validation styles that can be used to validate form inputs.
Syntax
To use Bootstrap's validation styles, add the was-validated
class to the form element, and add the required
attribute to the inputs that are required.
<form class="was-validated">
<div class="form-group">
<label for="inputName">Name</label>
<input type="text" class="form-control" id="inputName" placeholder="Enter name" required>
</div>
<div class="form-group">
<label for="inputEmail">Email address</label>
<input type="email" class="form-control" id="inputEmail" placeholder="Enter email" required>
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>