To change the default message of the required field in the popover of form-control in Bootstrap and JavaScript, we call the setCustomValidity
method.
For instance, we write
<input
class="form-control"
type="email"
required=""
placeholder="username"
oninvalid="this.setCustomValidity('Please Enter valid email')"
oninput="setCustomValidity('')"
/>
to add an input that sets the oninvalid
attribute to call setCustomValidity
with the validation message we want.
And we set oninput
to call setCustomValidity
to empty the validation message.