<form class="form-asd" role="form"> <h2 class="form-signin-heading">login</h2><hr /> <label class="control-label" for="username">Username</label> <input class="form-control" type="email" required="" placeholder="username"data-error="enter username"></input> <label class="control-label" for="username">password</label> <input class="form-control" type="password" required=" " placeholder="Password"></input> <label class="checkbox"></label> <button class="btn btn-lg btn-primary " type="submit">submit</button> </form>
how can we change this default message of popover of the require field "Please fill out this field "to "please enter username"
Vertical form (this is default)
Here's how form validation works with Bootstrap: HTML form validation is applied via CSS's two pseudo-classes, :invalid and :valid . It applies to <input> , <select> , and <textarea> elements. Bootstrap scopes the :invalid and :valid styles to parent .
You can use setCustomValidity
function when oninvalid
event occurs.
Like below:-
<input class="form-control" type="email" required="" placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')"> </input>
To clear the message once you start entering use oninput="setCustomValidity('')
attribute to clear the message.
<input class="form-control" type="email" required="" placeholder="username" oninvalid="this.setCustomValidity('Please Enter valid email')" oninput="setCustomValidity('')"></input>
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