Home
Features - Form Validation
Features - Form Validation
Form Validation - Bootstrap 4 Tooltips based
Bootstrap has a good validation engine, but sadly the alerts are not accessible. The template recommends usage of the Tooltips method, has changed some of the colors, and added aria-role="alret" to the invalid results so accessibility is maintained and the result is visible and declared to screen readers.
<form class= "needs-validation" novalidate >
<div class= "form-row" >
<div class= "col-md-4 mb-3" >
<label for= "validationTooltip01" > First name</label>
<input type= "text" class= "form-control" id= "validationTooltip01" placeholder= "First name" value= "Mark" required >
<div class= "valid-tooltip" >
Looks good!
</div>
</div>
<div class= "col-md-4 mb-3" >
<label for= "validationTooltip02" > Last name</label>
<input type= "text" class= "form-control" id= "validationTooltip02" placeholder= "Last name" value= "Otto" required >
<div class= "valid-tooltip" >
Looks good!
</div>
</div>
<div class= "col-md-4 mb-3" >
<label for= "validationTooltipUsername" > Username</label>
<div class= "input-group" >
<div class= "input-group-prepend" >
<span class= "input-group-text" id= "validationTooltipUsernamePrepend" > @</span>
</div>
<input type= "text" class= "form-control" id= "validationTooltipUsername" placeholder= "Username" aria-describedby= "validationTooltipUsernamePrepend" required >
<div class= "invalid-tooltip" role= "alert" >
Please choose a unique and valid username.
</div>
</div>
</div>
</div>
<div class= "form-row" >
<div class= "col-md-6 mb-3" >
<label for= "validationTooltip03" > City</label>
<input type= "text" class= "form-control" id= "validationTooltip03" placeholder= "City" required >
<div class= "invalid-tooltip" role= "alert" >
Please provide a valid city.
</div>
</div>
<div class= "col-md-3 mb-3" >
<label for= "validationTooltip04" > State</label>
<input type= "text" class= "form-control" id= "validationTooltip04" placeholder= "State" required >
<div class= "invalid-tooltip" role= "alert" >
Please provide a valid state.
</div>
</div>
<div class= "col-md-3 mb-3" >
<label for= "validationTooltip05" > Zip</label>
<input type= "text" class= "form-control" id= "validationTooltip05" placeholder= "Zip" required >
<div class= "invalid-tooltip" role= "alert" >
Please provide a valid zip.
</div>
</div>
</div>
<button class= "btn btn-primary" type= "submit" > Submit form</button>
</form>
for full options and codes‚ please visit the Bootstrap 4 validation pageNew Window icon This link opens a new window or tab .
Scroll To Top