JSF Validator + Regular expression authentication password, two times password is consistent function.
Requirements Description :
1, password and confirmation after the display (consisting of 10-15-digit letters or numbers)
2, two times the password is inconsistent when the confirmation password prompts
3, after changing the content, verify by prompting the message again (consisting of 10-15-digit letters or numbers)
Implementation Code
1, page code
<span style= "FONT-SIZE:18PX;" >
The Patten content in the Validateregex label is to verify the content format entered in the current text box; Validatormessage indicates that the content displayed when the validation is not passed, the font is red, and onblur is the JS method that starts after losing focus.
The Rich:message label is the label for the prompt on the interface and is bound to the Password box.
2,js method
<span style= "FONT-SIZE:18PX;" >function Check () {
//Get password prompt information
var passwd = document.getElementById ("userform:passwordmsg");
Determine if the Firefox browser if (
window.navigator.userAgent.toLowerCase (). IndexOf (' Firefox '!=-1)) {
if ( passwd.textcontent== "") {
passwd.style.color= "Groy";
Passwd.textcontent= "consists of 10-15-digit letters or numbers";
}
else{
if (passwd.innertext== "") {
passwd.style.color= "Groy";
Passwd.innertext= "consists of 10-15-digit letters or numbers"
;
}} </span>
<span style= "FONT-SIZE:18PX;" >function checkpswd () {
//Get password, confirm password and Confirm password prompt information
var pswd = document.getElementById ("userform:pswd");
var repswd = document.getElementById ("userform:repswd");
var repasswd = document.getElementById ("userform:repasswordmsg");
Determine if the password is consistent
if (pswd.value!=repswd.value) {
//Set the hint message for, the password inconsistent
repasswd.style.color= "red";
if (Window.navigator.userAgent.toLowerCase (). IndexOf (' Firefox '!=-1)) {
repasswd.textcontent= "password inconsistent";
} else{
repasswd.innertext= "password inconsistent";
}
else{
//Set hint information for, composed of 10-15-digit letters or numbers
repasswd.style.color= "gray";
if (Window.navigator.userAgent.toLowerCase (). IndexOf (' Firefox '!=-1)) {
repasswd.textcontent= "consists of 10-15-digit letters or numbers ";
} else{
repasswd.innertext= "consists of 10-15-digit letters or numbers";}}
</span>