Location: PHPKode > scripts > Compare Validator > CompareValidator.php
<?PHP
    class CompareValidator
    {
        private $data=array();

        public function CompareValidator($name)
        {
            $this->data['Name']=$name;
            $this->data['BackColor']='#ffff00';
            $this->data['BorderColor']='#ff0000';
            $this->data['ControlToCompare']='';
            $this->data['ControlToValidate']='';
            $this->data['Font']='Tahoma';
            $this->data['ForeColor']='#ff0000';
            $this->data['Height']='25';
            $this->data['Text']='اطلاعات وارد شده يكسان نيست';
            $this->data['Width']='250';
        }

        public function Draw()
        {
            echo '<DIV id="div'.$this->data['Name'].'" style="';
            echo 'background-color: '.$this->data['BackColor'].'; ';
            echo 'border-color: '.$this->data['BorderColor'].'; ';
            echo 'border: solid; ';
            echo 'font-family: '.$this->data['Font'].'; ';
            echo 'color: '.$this->data['ForeColor'].'; ';
            echo 'height: '.$this->data['Height'].'px; ';
            echo 'width: '.$this->data['Width'].'px;"';
            echo '></DIV>'."\n";
            echo '<INPUT type="hidden" name="inp'.$this->data['Name'].'" id="inp'.$this->data['Name'].'" value="">'."\n";
            echo '<SCRIPT language="javascript" type="text/javascript">'."\n";
            echo '    function '.$this->data['Name'].'()'."\n";
            echo '    {'."\n";
            echo '        var cmp = document.getElementById(\''.$this->data['ControlToCompare'].'\');'."\n";
            echo '        var vld = document.getElementById(\''.$this->data['ControlToValidate'].'\');'."\n";
            echo '        var div = document.getElementById(\'div'.$this->data['Name'].'\');'."\n";
            echo '        var inp = document.getElementById(\'inp'.$this->data['Name'].'\');'."\n";
            echo '        div.innerHTML = (cmp.value!=vld.value?\''.$this->data['Text'].'\':\'\')'."\n";
            echo '        inp.value = (div.innerHTML==\'\'?\'true\':\'false\')'."\n";
            echo '    }'."\n";
            echo '</SCRIPT>'."\n";
        }

        public function __get($name)
        {
            if(array_key_exists($name,$this->data))
            {
                return $this->data[$name];
            }
        }

        public function __set($name,$value)
        {
            if(array_key_exists($name,$this->data))
            {
                $this->data[$name]=$value;
            }
        }
    }
?>
Return current item: Compare Validator