Location: PHPKode > projects > So Easy PHP > SoEasy/EasyHtml/HtmlMaker/FormValidate/Validators/IsEqualValidator.class.php
<?php
include_once "HtmlMaker/FormValidate/FormFieldValidate.class.php";

/**
 * Verifica se o conteúdo de dois campos de formulário são iguais
 *
 * @author Ricardo Valeriano <hide@address.com>
 * @since 19/12/2006 16:09:24
 * @package EasyHtml
 * @subpackage FormValidate
 */
final class IsEqualValidator extends FormFieldValidate {
	
	/**
	 * @var string valor para comparação
	 * @access private
	 */
	private $fieldToCompare;
	
	/**
	 * @param FormField campo de formulário para comparar
	 */
	public function IsEqualValidator(FormField $fieldToCompare) {
		$this->FormFieldValidate();
		$this->fieldToCompare = $fieldToCompare;
	}

	public function loadJavaScriptCode() {
		$code = null;
		$code .= "campo_um = " . $this->getJavaScriptFieldName($this->getField()) .";";
		$code .= "campo_dois = " . $this->getJavaScriptFieldName($this->fieldToCompare) .";";
		$code .= "return (campo_um.value == campo_dois.value);";
		$this->setJavaScriptCode($code);
	}

	protected function validatorExecute() {
		return ( $this->getField()->getValue() === $this->fieldToCompare->getValue() );
	}
}
?>
Return current item: So Easy PHP