コード例 #1
0
 /**
  * This Form_Validate event handler allows you to specify any custom Form Validation rules.
  * It will also Blink() on all invalid controls, as well as Focus() on the top-most invalid control.
  */
 protected function Form_Validate()
 {
     // By default, we report the result of validation from the parent
     $blnToReturn = parent::Form_Validate();
     // Custom Validation Rules
     // TODO: Be sure to set $blnToReturn to false if any custom validation fails!
     // Check for records that may violate Unique Clauses
     if (($objNarroUser = NarroUser::LoadByUsername($this->txtUsername->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtUsername->Warning = QApplication::Translate("Already in Use");
     }
     if (($objNarroUser = NarroUser::LoadByEmail($this->txtEmail->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtEmail->Warning = QApplication::Translate("Already in Use");
     }
     if (($objNarroUser = NarroUser::LoadByRealName($this->txtRealName->Text)) && $objNarroUser->UserId != $this->mctNarroUser->NarroUser->UserId) {
         $blnToReturn = false;
         $this->txtRealName->Warning = QApplication::Translate("Already in Use");
     }
     $blnFocused = false;
     foreach ($this->GetErrorControls() as $objControl) {
         // Set Focus to the top-most invalid control
         if (!$blnFocused) {
             $objControl->Focus();
             $blnFocused = true;
         }
         // Blink on ALL invalid controls
         $objControl->Blink();
     }
     return $blnToReturn;
 }