Is it possible to control HTML5 alert messages? when adding 'required' to an input field.
because I want it to be specific and I don't want it's language to depend on the browsers.
<input id="answer" required>
Is it possible to control HTML5 alert messages? when adding 'required' to an input field.
because I want it to be specific and I don't want it's language to depend on the browsers.
<input id="answer" required>
You can use customValidity
$(function(){
var elements = document.getElementsByTagName("input");
for (var i = 0; i < elements.length; i++) {
elements[i].oninvalid = function(e) {
e.target.setCustomValidity("This can't be left blank!");
};
}
});
I think that will work on at least Chrome and FF, I'm not sure about other browsers
Thank you guys for the help,
When I asked at first I didn't think it's even possible, but after your answers I googled and found this amazing tutorial:
Yes:
<input required title="Enter something OR ELSE." />
The title
attribute will be used to notify the user of a problem.