Question

I want to display a message on my HTML page to instruct users for what is allowed in Password field. I have following in my HTML markup

<input type="Password" data-val="true" name="password"/>

What are all allowed values for HTML Password inputs?

Was it helpful?

Solution

Since you're using the data-val attribute, i assume you're using the unobtrusive version of .

See this article for a comprehensive list of validation rules.

OTHER TIPS

<input type="Password" data-val="true" name="password" required maxlength=”15” minlength=”4” pattern=”[1-4]{5}” />

HTML

<form name="ValidationForm">
    Password: <input type="password" id="password1"/>
    Confirm Password:<input type="password" id="password2"/>
    <input type="submit" value="submit"/>
</form>

JS

<script type="text/javascript">
window.onload = function () {
    document.getElementById("password1").onchange = validatePassword;
    document.getElementById("password2").onchange = validatePassword;
}
function validatePassword(){
var pass2=document.getElementById("password2").value;
var pass1=document.getElementById("password1").value;
if(pass1!=pass2)
    document.getElementById("password2").setCustomValidity("Passwords Don't Match");
else
    document.getElementById("password2").setCustomValidity('');  
//empty string means no validation error
}
</script>

sure you can use JQuery rather than row JS

http://dev.w3.org/html5/markup/input.password.html

Value: Any string that contains no line feed (U+000A, “LF”) or carriage return (U+000D, “CR”) characters.

In other words, by default you can put pretty much any text in there you like, with the two exceptions above.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top