Use of JSF tag verifier __js

Source: Internet
Author: User

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>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.