public
anonymous / gist:1103051
Created

3.8.1 Customizing the validation messages

  • Download Gist
gistfile1.html
HTML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script>
function addCustomValidation() {
var fldName = document.getElementById('fullname');
fldName.form.onsubmit = function () {
fldName.setCustomValidity("");
if (!fldName.validity.valid) {
fldName.setCustomValidity("Nameless ones are not allowedto take part");
}
};
}
</script>
</head>
<body onload="javascript:addCustomValidation();">
<form>
<label>Full name: <input id="fullname" /></label> <br/>
<input type="submit" value="Enviar">
</form>
</body>
</html>

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.