summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitattributes2
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php2
-rw-r--r--demos/quickstart/protected/pages/Controls/Validation.page33
-rw-r--r--framework/Web/UI/WebControls/TCompareValidator.php7
-rw-r--r--framework/Web/UI/WebControls/TCustomValidator.php2
-rw-r--r--framework/Web/UI/WebControls/TDataTypeValidator.php (renamed from framework/Web/UI/WebControls/TValueTypeValidator.php)7
6 files changed, 40 insertions, 13 deletions
diff --git a/.gitattributes b/.gitattributes
index f59e7084..0d8b8ab2 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -713,6 +713,7 @@ framework/Web/UI/WebControls/TDataGridColumn.php -text
framework/Web/UI/WebControls/TDataList.php -text
framework/Web/UI/WebControls/TDataSourceControl.php -text
framework/Web/UI/WebControls/TDataSourceView.php -text
+framework/Web/UI/WebControls/TDataTypeValidator.php -text
framework/Web/UI/WebControls/TDatePicker.php -text
framework/Web/UI/WebControls/TDropDownList.php -text
framework/Web/UI/WebControls/TEditCommandColumn.php -text
@@ -754,7 +755,6 @@ framework/Web/UI/WebControls/TTemplateColumn.php -text
framework/Web/UI/WebControls/TTextBox.php -text
framework/Web/UI/WebControls/TTextHighlighter.php -text
framework/Web/UI/WebControls/TValidationSummary.php -text
-framework/Web/UI/WebControls/TValueTypeValidator.php -text
framework/Web/UI/WebControls/TWebControl.php -text
framework/Web/UI/WebControls/TWebControlAdapter.php -text
framework/Web/UI/WebControls/TWizard.php -text
diff --git a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php
index 2b18972d..2309bd88 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php
+++ b/demos/quickstart/protected/pages/Controls/Samples/LabeledTextBox1/Home.php
@@ -1,6 +1,6 @@
<?php
-Prado::using('Application.pages.Controls.Samples.LabeledTextBox2.LabeledTextBox');
+Prado::using('Application.pages.Controls.Samples.LabeledTextBox1.LabeledTextBox');
class Home extends TPage
{
diff --git a/demos/quickstart/protected/pages/Controls/Validation.page b/demos/quickstart/protected/pages/Controls/Validation.page
index fe801183..766925ca 100644
--- a/demos/quickstart/protected/pages/Controls/Validation.page
+++ b/demos/quickstart/protected/pages/Controls/Validation.page
@@ -129,17 +129,46 @@ Note, if the value being validated is empty, TEmailAddressValidator will not do
<h2>TRangeValidator</h2>
<p>
+TRangeValidator tests whether an input value is within a specified range.
</p>
+<p>
+TRangeValidator uses three key properties to perform its validation. The <tt>MinValue</tt> and <tt>MaxValue</tt> properties specify the minimum and maximum values of the valid range. The <tt>ValueType</tt> property specifies the data type of the value being validated. The value will be first converted into the specified type and then compare with the valid range. The following value types are supported:
+</p>
+<ul>
+<li><tt>String</tt> - A string data type.</li>
+<li><tt>Integer</tt> - A 32-bit signed integer data type.</li>
+<li><tt>Float</tt> - A double-precision floating point number data type.</li>
+<li><tt>Currency</tt> - A decimal data type that can contain currency symbols.</li>
+<li><tt>Date</tt> - A date data type. The date format can be specified by setting <tt>DateFormat</tt> property, which must be recognizable by <tt>TSimpleDateFormatter</tt>. If the property is not set, the GNU date syntax is assumed.</li>
+</ul>
<com:RunBar PagePath="Controls.Samples.TRangeValidator.Home" />
-<h2>TValueTypeValidator</h2>
+<h2>TDataTypeValidator</h2>
<p>
</p>
-<com:RunBar PagePath="Controls.Samples.TValueTypeValidator.Home" />
+<com:RunBar PagePath="Controls.Samples.TDataTypeValidator.Home" />
<h2>TCustomValidator</h2>
<p>
+TCustomValidator performs user-defined validation (either server-side or client-side or both) on an input control.
+</p>
+<p>
+To create a server-side validation function, provide a handler for the <tt>OnServerValidate</tt> event that performs the validation. The data string of the input control to validate can be accessed by the event parameter's <tt>Value</tt> property. The result of the validation should be stored in the <tt>IsValid</tt> property of the parameter.
+</p>
+<p>
+To create a client-side validation function, add the client-side validation javascript function to the page template and assign its name to the <tt>ClientValidationFunction</tt> property. The function should have the following signature:
</p>
+<com:TTextHighlighter Language="javascript" CssClass="source">
+<script type="text/javascript">
+function ValidationFunctionName(sender, parameter)
+{
+ // if(parameter == ...)
+ // return true;
+ // else
+ // return false;
+}
+</script>
+</com:TTextHighlighter>
<com:RunBar PagePath="Controls.Samples.TCustomValidator.Home" />
diff --git a/framework/Web/UI/WebControls/TCompareValidator.php b/framework/Web/UI/WebControls/TCompareValidator.php
index 9b8dabd5..6cc9d0e5 100644
--- a/framework/Web/UI/WebControls/TCompareValidator.php
+++ b/framework/Web/UI/WebControls/TCompareValidator.php
@@ -30,7 +30,7 @@ Prado::using('System.Web.UI.WebControls.TBaseValidator');
* of both comparison values. Both values are automatically converted to this data
* type before the comparison operation is performed. The following value types are supported:
* - <b>Integer</b> A 32-bit signed integer data type.
- * - <b>Double</b> A double-precision floating point number data type.
+ * - <b>Float</b> A double-precision floating point number data type.
* - <b>Currency</b> A decimal data type that can contain currency symbols.
* - <b>Date</b> A date data type. The format follows the GNU date syntax.
* - <b>String</b> A string data type.
@@ -61,12 +61,12 @@ class TCompareValidator extends TBaseValidator
}
/**
- * Sets the data type (Integer, Double, Currency, Date, String) that the values being compared are converted to before the comparison is made.
+ * Sets the data type (Integer, Float, Currency, Date, String) that the values being compared are converted to before the comparison is made.
* @param string the data type
*/
public function setValueType($value)
{
- $this->setViewState('ValueType',TPropertyValue::ensureEnum($value,'Integer','Double','Date','Currency','String'),'String');
+ $this->setViewState('ValueType',TPropertyValue::ensureEnum($value,'Integer','Float','Date','Currency','String'),'String');
}
/**
@@ -192,7 +192,6 @@ class TCompareValidator extends TBaseValidator
case 'Integer':
return array(intval($value1), intval($value2));
case 'Float':
- case 'Double':
return array(floatval($value1), floatval($value2));
case 'Currency':
if(preg_match('/[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?/',$value1,$matches))
diff --git a/framework/Web/UI/WebControls/TCustomValidator.php b/framework/Web/UI/WebControls/TCustomValidator.php
index e92ae828..b72ec344 100644
--- a/framework/Web/UI/WebControls/TCustomValidator.php
+++ b/framework/Web/UI/WebControls/TCustomValidator.php
@@ -116,7 +116,7 @@ class TCustomValidator extends TBaseValidator
* TServerValidateEventParameter class
*
* TServerValidateEventParameter encapsulates the parameter data for
- * <b>ServerValidate</b> event of TCustomValidator components.
+ * <b>OnServerValidate</b> event of TCustomValidator components.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
diff --git a/framework/Web/UI/WebControls/TValueTypeValidator.php b/framework/Web/UI/WebControls/TDataTypeValidator.php
index 8b5d7bbc..daaa9b6e 100644
--- a/framework/Web/UI/WebControls/TValueTypeValidator.php
+++ b/framework/Web/UI/WebControls/TDataTypeValidator.php
@@ -1,6 +1,6 @@
<?php
/**
- * TValueTypeValidator class.
+ * TDataTypeValidator class.
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @link http://www.pradosoft.com/
@@ -16,14 +16,14 @@
Prado::using('System.Web.UI.WebControls.TBaseValidator');
/**
- * TValueTypeValidator class
+ * TDataTypeValidator class
*
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
* @version $Revision: $ $Date: $
* @package System.Web.UI.WebControls
* @since 3.0
*/
-class TValueTypeValidator extends TBaseValidator
+class TDataTypeValidator extends TBaseValidator
{
/**
* @return string the data type that the values being compared are converted to before the comparison is made. Defaults to String.
@@ -72,7 +72,6 @@ class TValueTypeValidator extends TBaseValidator
case 'Integer':
return preg_match('/^[-+]?[0-9]+$/',trim($value));
case 'Float':
- case 'Double':
return preg_match('/^[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value));
case 'Currency':
return preg_match('/[-+]?([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?$/',trim($value));