문제

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?

도움이 되었습니까?

해결책

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.

다른 팁

<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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top