Created
February 4, 2017 19:15
-
-
Save KiT106/0ed3813492e73813cfabdd625bd3929a to your computer and use it in GitHub Desktop.
HTML form custom validation message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("input").on("invalid", function(e) { | |
if (this.validity.valueMissing){ | |
this.setCustomValidity("valueMissing"); | |
} | |
if (this.validity.tooShort){ | |
this.setCustomValidity("tooShort"); | |
} | |
// .... more custom message here. | |
}); | |
$("input").on("input", function(e) { | |
this.setCustomValidity(""); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form id="form"> | |
<input name="username" type="text" placeholder="Username" required minlength="6"> | |
<input name="password" type="password" placeholder="Password" required> | |
<br/>Remember me: | |
<input type="checkbox" name="remember" value="true" > | |
<br/> | |
<input type="submit" name="submit" value="Log In"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment