Пример #1
0
 public function Validate()
 {
     if (parent::Validate()) {
         if ($this->strText != "") {
             try {
                 $this->strText = QType::Cast($this->strText, QType::Integer);
             } catch (QInvalidCastException $objExc) {
                 $this->strValidationError = $this->strLabelForInvalid;
                 return false;
             }
             if (!is_numeric($this->strText)) {
                 $this->strValidationError = $this->strLabelForInvalid;
                 return false;
             }
             if (!is_null($this->intMinimum) && $this->strText < $this->intMinimum) {
                 $this->strValidationError = sprintf($this->strLabelForGreater, $this->intMinimum);
                 return false;
             }
             if (!is_null($this->intMaximum) && $this->strText > $this->intMaximum) {
                 $this->strValidationError = sprintf($this->strLabelForLess, $this->intMaximum);
                 return false;
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = "";
     return true;
 }
		public function Validate() {
			if (parent::Validate()) {
				if ($this->strText != '') {
					try {
						$this->strText = QType::Cast($this->strText, QType::Float);
					} catch (QInvalidCastException $objExc) {
						$this->strValidationError = $this->strLabelForInvalid;
						return false;
					}
					
					if ((!is_null($this->fltMinimum)) && ($this->strText < $this->fltMinimum)) {
						$this->strValidationError = sprintf($this->strLabelForGreater, $this->fltMinimum);
						return false;
					}

					if ((!is_null($this->fltMaximum)) && ($this->strText > $this->fltMaximum)) {
						$this->strValidationError = sprintf($this->strLabelForLess, $this->fltMaximum);
						return false;
					}
				}
			} else
				return false;

			$this->strValidationError = '';
			return true;
		}
Пример #3
0
 public function Validate()
 {
     if (parent::Validate()) {
         if (trim($this->strText) != "") {
             $this->strText = trim($this->strText);
             $strOriginal = $this->strText;
             $strFinal = '';
             while (strlen($strOriginal)) {
                 if (is_numeric(QString::FirstCharacter($strOriginal))) {
                     $strFinal .= QString::FirstCharacter($strOriginal);
                 }
                 if (strtolower(QString::FirstCharacter($strOriginal)) == 'x') {
                     $strFinal .= 'x';
                 }
                 $strOriginal = substr($strOriginal, 1);
             }
             if (strlen($strFinal) == 10 && strpos($strFinal, 'x') === false) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6);
                 $this->strValidationError = null;
                 return true;
             }
             if (strlen($strFinal) > 11 && strpos($strFinal, 'x') == 10 && strpos($strFinal, 'x', 11) === false && strlen($strFinal) <= 17) {
                 $this->strText = substr($strFinal, 0, 3) . '-' . substr($strFinal, 3, 3) . '-' . substr($strFinal, 6, 4) . ' ' . substr($strFinal, 10);
                 $this->strValidationError = null;
                 return true;
             }
             $this->strValidationError = 'For example "213-555-1212" or "213-555-1212 x123"';
             return false;
         }
     } else {
         return false;
     }
     $this->strValidationError = null;
     return true;
 }
Пример #4
0
 public function Validate()
 {
     $this->strValidationError = "";
     if (parent::Validate()) {
         // Blank strings should always validate to true
         // unless this control is "required", in which case
         // parent::validate() would've already caught that
         if (strlen($this->strText) == 0) {
             return true;
         }
         if (strlen($this->strText)) {
             $strMatchesArray = null;
             if (preg_match("/[A-Za-z0-9]+/", $this->strText, $strMatchesArray)) {
                 if ($strMatchesArray[0] == $this->strText) {
                     // We Matched -- Now Check for Duplicates
                     $strListArray = explode(" ", $this->strUniqueList);
                     $strKey = array_search($this->strText, $strListArray);
                     if (strlen($strKey) == 0) {
                         return true;
                     }
                     $this->strValidationError = "Token already exists";
                     return false;
                 }
             }
         }
         $this->strValidationError = "Must only contain AlphaNumeric characters";
         return false;
     }
 }
Пример #5
0
 public function Validate()
 {
     if (!parent::Validate()) {
         return false;
     }
     if (strlen(trim($this->strText)) && !QEmailServer::IsEmailValid($this->strText)) {
         $this->strValidationError = $this->strLabelForInvalid;
         return false;
     }
     $this->strValidationError = '';
     return true;
 }
Пример #6
0
 public function Validate()
 {
     if (parent::Validate()) {
         if (!preg_match('%^[\\w:/@?&#.]*$%', $this->strText)) {
             $this->strValidationError = $this->strLabelForInvalid;
             return false;
         }
     } else {
         return false;
     }
     $this->strValidationError = '';
     return true;
 }
Пример #7
0
 public function Validate()
 {
     if (parent::Validate()) {
         if (trim($this->strText) != "") {
             $objResult = $this->ValidateUrl($this->strText);
             if ($objResult["Result"] != EW_OK) {
                 $this->strValidationError = "Invalid URL";
                 return false;
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = "";
     return true;
 }
 /**
  * Validate the control, setting validation error if there is a problem.
  * @return bool
  */
 public function Validate()
 {
     $blnRet = parent::Validate();
     if ($blnRet) {
         $a = str_getcsv($this->strText);
         if ($this->intMinItemCount !== null && count($a) < $this->intMinItemCount) {
             $this->ValidationError = sprintf($this->strLabelForTooShort, $this->intMinItemCount);
             return false;
         }
         if ($this->intMaxItemCount !== null && count($a) > $this->intMaxItemCount) {
             $this->ValidationError = sprintf($this->strLabelForTooLong, $this->intMaxItemCount);
             return false;
         }
     }
     // If we're here, then everything is a-ok.  Return true.
     return true;
 }
Пример #9
0
 public function Validate()
 {
     if (parent::Validate()) {
         if (strlen(trim($this->strText))) {
             // RegExp taken from php.net
             $this->strText = trim($this->strText);
             $strEmailAddressArray = QEmailServer::GetEmailAddresses($this->strText);
             if (count($strEmailAddressArray) != 1 || strtolower($strEmailAddressArray[0]) != strtolower($this->strText)) {
                 $this->strValidationError = "Invalid e-mail address";
                 return false;
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = "";
     return true;
 }
 /**
  * @return bool whether or not the input passed all the values
  */
 public function Validate()
 {
     if (parent::Validate()) {
         if ($this->strText != "") {
             try {
                 $this->strText = QType::Cast($this->strText, $this->strDataType);
             } catch (QInvalidCastException $objExc) {
                 $this->ValidationError = $this->strLabelForInvalid;
                 $this->MarkAsModified();
                 return false;
             }
             if (!is_numeric($this->strText)) {
                 $this->ValidationError = $this->strLabelForInvalid;
                 $this->MarkAsModified();
                 return false;
             }
             if (!is_null($this->mixStep)) {
                 $newVal = QType::Cast(round(($this->strText - $this->mixMinimum) / $this->mixStep) * $this->mixStep + $this->mixMinimum, $this->strDataType);
                 if ($newVal != $this->strText) {
                     if ($this->strLabelForNotStepAligned) {
                         $this->ValidationError = sprintf($this->strLabelForNotStepAligned, $this->mixStep);
                         $this->MarkAsModified();
                         return false;
                     }
                     $this->strText = $newVal;
                     $this->MarkAsModified();
                 }
             }
             if (!is_null($this->mixMinimum) && $this->strText < $this->mixMinimum) {
                 $this->ValidationError = sprintf($this->strLabelForGreater, $this->mixMinimum);
                 $this->MarkAsModified();
                 return false;
             }
             if (!is_null($this->mixMaximum) && $this->strText > $this->mixMaximum) {
                 $this->ValidationError = sprintf($this->strLabelForLess, $this->mixMaximum);
                 $this->MarkAsModified();
                 return false;
             }
         }
     } else {
         return false;
     }
     return true;
 }
Пример #11
0
 public function Validate()
 {
     if (parent::Validate()) {
         if ($this->strText != "") {
             $dttTest = QDateTimeTextBox::ParseForDateTimeValue($this->strText);
             if (!$dttTest) {
                 $this->strValidationError = $this->strLabelForInvalid;
                 return false;
             }
             if (!is_null($this->dttMinimum)) {
                 if ($this->dttMinimum == QDateTime::Now) {
                     $dttToCompare = new QDateTime(QDateTime::Now);
                     $strError = 'in the past';
                 } else {
                     $dttToCompare = $this->dttMinimum;
                     $strError = 'before ' . $this->dttMinimum->__toString();
                 }
                 if ($dttTest->IsEarlierThan($dttToCompare)) {
                     $this->strValidationError = 'Date cannot be ' . $strError;
                     return false;
                 }
             }
             if (!is_null($this->dttMaximum)) {
                 if ($this->dttMaximum == QDateTime::Now) {
                     $dttToCompare = new QDateTime(QDateTime::Now);
                     $strError = 'in the future';
                 } else {
                     $dttToCompare = $this->dttMaximum;
                     $strError = 'after ' . $this->dttMaximum->__toString();
                 }
                 if ($dttTest->IsLaterThan($dttToCompare)) {
                     $this->strValidationError = 'Date cannot be ' . $strError;
                     return false;
                 }
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = '';
     return true;
 }
Пример #12
0
 public function Validate()
 {
     if (parent::Validate()) {
         $this->strText = trim($this->strText);
         if ($this->strText != "") {
             if ($this->strDefaultAreaCode) {
                 $pattern = "(\\(||\\[)?\\d{3}(\\)||\\])?[-\\s.]+\\d{3}[-\\s.]+\\d{4}( x\\d+)?\$";
                 // standard phone
             } else {
                 $pattern = "((\\(||\\[)?\\d{3}(\\)||\\])?[-\\s.]+)?\\d{3}[-\\s.]+\\d{4}( x\\d+)?\$";
                 // optional area code
             }
             if (!preg_match("/{$pattern}/", $this->strText)) {
                 $this->ValidationError = QApplication::Translate("Invalid phone number");
                 return false;
             }
         }
     } else {
         return false;
     }
     $this->strValidationError = "";
     return true;
 }