summaryrefslogtreecommitdiff
path: root/demos/quickstart/protected
diff options
context:
space:
mode:
authorwei <>2007-03-27 08:34:28 +0000
committerwei <>2007-03-27 08:34:28 +0000
commitd5950ec0b553d46c4800adc0532d4464a4eb1883 (patch)
tree232a4f5ccbd36d6a114dff383adb383793422814 /demos/quickstart/protected
parentcdf3ba1c190393d86460f8c13073dc9784436b3e (diff)
Fixed #278, conditional validation.
Diffstat (limited to 'demos/quickstart/protected')
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page25
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php8
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page63
-rw-r--r--demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php18
-rw-r--r--demos/quickstart/protected/pages/Controls/Validation.page31
-rw-r--r--demos/quickstart/protected/pages/GettingStarted/Introduction.page3
6 files changed, 92 insertions, 56 deletions
diff --git a/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page
new file mode 100644
index 00000000..44f84abe
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.page
@@ -0,0 +1,25 @@
+<com:TContent ID="body">
+
+<h1>Reset Validation using Javascript</h1>
+
+<table class="sampletable">
+
+<tr>
+<td class="samplenote">
+Validator with default settings:
+</td>
+<td class="sampleaction">
+<com:TTextBox ID="TextBox1" />
+<com:TRequiredFieldValidator
+ ValidationGroup="Group1"
+ ControlToValidate="TextBox1"
+ Text="Field required." />
+<com:TButton Text="Submit" ValidationGroup="Group1" />
+
+<a href="javascript: Prado.Validation.reset('Group1')">Reset Validation</a>
+</td>
+</tr>
+
+</table>
+
+<div class="last-modified">$Id: Home.page 1650 2007-01-24 06:55:32Z wei $</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php
new file mode 100644
index 00000000..88d2dbf2
--- /dev/null
+++ b/demos/quickstart/protected/pages/Controls/Samples/ResetValidation/Home.php
@@ -0,0 +1,8 @@
+<?php
+
+class Home extends TPage
+{
+
+}
+
+?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page
index c70e04c7..76ecb845 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page
+++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.page
@@ -1,41 +1,36 @@
<com:TContent ID="body">
- <h1>Validator Toggle - Server and Client Side</h1>
- <com:TLabel ForControl="text1" Text="Text 1:" />
- <com:TTextBox ID="text1" />
- <com:TRequiredFieldValidator
- ID="validator1"
- ControlToValidate="text1"
- ErrorMessage="Text 1 is required" />
- <div>
- <com:TCheckBox ID="check1" Text="More..." />
- </div>
+<h1>Conditional Validation (client-side + server side)</h1>
- <com:TPanel ID="panel1" Style="display:none" >
- <com:TLabel ForControl="text2" Text="Text 2:" />
+<table class="sampletable">
+<tr>
+<td class="samplenote">
+Validator with default settings:<br />
+Check "optional" to validate both textboxes
+</td>
+<td class="sampleaction">
+ <com:TTextBox ID="text1" />
+ <com:TRequiredFieldValidator
+ ID="validator1"
+ ControlToValidate="text1"
+ ErrorMessage="*"
+ ControlCssClass="required"/>
<com:TTextBox ID="text2" />
+ <com:TRequiredFieldValidator
+ ID="validator2"
+ ControlToValidate="text2"
+ OnValidate="check_validate"
+ ErrorMessage="*"
+ ControlCssClass="required">
+ <prop:ClientSide.OnValidate>
+ sender.enabled = $('<%= $this->check1->ClientID %>').checked;
+ </prop:ClientSide.OnValidate>
- <com:TRequiredFieldValidator
- ID="validator2"
- ControlToValidate="text2"
- OnValidate="validator2_onValidate"
- OnPreRender="validate2_onPostValidate"
- ErrorMessage="Text 2 is required">
- <prop:ClientSide.OnValidate>
- sender.enabled = $("<%= $this->check1->ClientID %>").checked;
- </prop:ClientSide.OnValidate>
- </com:TRequiredFieldValidator>
+ </com:TRequiredFieldValidator>
+ <com:TCheckBox ID="check1" Text="Optional" />
+ <com:TButton ID="submit1" Text="Submit" />
+</td>
+</tr>
- </com:TPanel>
+</table>
- <com:TButton ID="button1" Text="Submit!" />
-
- <com:TClientScript>
- Event.OnLoad(function()
- {
- Event.observe("<%= $this->check1->ClientID %>", "click", function(ev)
- {
- $("<%= $this->panel1->ClientID %>").toggle();
- });
- });
- </com:TClientScript>
<div class="last-modified">$Id$</div></com:TContent> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php
index c5440996..d6dded08 100644
--- a/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php
+++ b/demos/quickstart/protected/pages/Controls/Samples/TClientSideValidator/Home.php
@@ -2,22 +2,16 @@
class Home extends TPage
{
- function validator2_onValidate($sender, $param)
+ function check_validate($sender, $params)
{
- $sender->Enabled = $this->check1->Checked;
+ $sender->enabled = $this->check1->checked;
}
-
- function validate2_onPostValidate($sender, $param)
- {
- $sender->Enabled = true;
- }
-
+
function onPreRender($param)
{
- parent::onPreRender($param);
- $this->panel1->Style =
- $this->check1->Checked ? "display:block" : "display:none";
- }
+ //always re-enable the validator2 so as to display the client-side validator
+ $this->validator2->enabled=true;
+ }
}
?> \ No newline at end of file
diff --git a/demos/quickstart/protected/pages/Controls/Validation.page b/demos/quickstart/protected/pages/Controls/Validation.page
index 38699550..b93f6d49 100644
--- a/demos/quickstart/protected/pages/Controls/Validation.page
+++ b/demos/quickstart/protected/pages/Controls/Validation.page
@@ -31,14 +31,7 @@ Validators share a common set of properties, which are defined in the base class
<li><tt>FocusElementID</tt> - the ID of the HTML element that will receive focus if validation fails and <tt>FocusOnError</tt> is true.</li>
</ul>
-<h1 id="123123">Interacting the Validators with Javascript</h1>
-<h2>Resetting or Clearing of Validators</h2>
-<p id="1212323">
-Validators can be reset on the client-side using javascript by calling the
-<tt>Prado.Validation.reset(groupID)</tt> where <tt>groupID</tt> is the validator
-grouping name. If <tt>groupID</tt> is null, then validators without grouping are used.
-</p>
-
+<h1>Prado Validation Controls</h1>
<a name="TRequiredFieldValidator"></a>
<h2 id="4902">TRequiredFieldValidator</h2>
<p id="560340" class="block-content">
@@ -159,6 +152,24 @@ The summary can be displayed as a list, a bulleted list, or a single paragraph b
</p>
<com:RunBar PagePath="Controls.Samples.TValidationSummary.Home" />
+<h1 id="123123">Interacting the Validators</h1>
+<h2>Resetting or Clearing of Validators</h2>
+<p id="1212323">
+Validators can be reset on the client-side using javascript by calling the
+<tt>Prado.Validation.reset(groupID)</tt> where <tt>groupID</tt> is the validator
+grouping name. If <tt>groupID</tt> is null, then validators without grouping are used.
+</p>
+
+<com:TTextHighlighter Language="javascript" CssClass="source block-content" id="code_560118a">
+<script type="text/javascript">
+function reset_validator()
+{
+ Prado.Validation.reset("group1");
+}
+</script>
+</com:TTextHighlighter>
+<com:RunBar PagePath="Controls.Samples.ResetValidation.Home" />
+
<h2 id="5301">Client and Server Side Conditional Validation</h2>
<p id="560359" class="block-content">
All validators contains the following events.
@@ -191,7 +202,9 @@ is the control that invoked the validator.
<h3 id="5302">Conditional Validation Example</h3>
<p id="560361" class="block-content">
The following example show the use of client-side and server side validator events. The example
-demonstrates conditional validation.
+demonstrates conditional validation. Notice that, we need to write code for both the
+server side and client-side. Moreover, on the server side, we need to re-enable the conditional
+validator so that its javascript code are produced no matter what (otherwise, the client-side validator is not available).
<com:RunBar PagePath="Controls.Samples.TClientSideValidator.Home" />
</p>
diff --git a/demos/quickstart/protected/pages/GettingStarted/Introduction.page b/demos/quickstart/protected/pages/GettingStarted/Introduction.page
index e48360d6..f267d23d 100644
--- a/demos/quickstart/protected/pages/GettingStarted/Introduction.page
+++ b/demos/quickstart/protected/pages/GettingStarted/Introduction.page
@@ -7,6 +7,7 @@ This Quickstart tutorial is provided to help you quickly start building your own
<p>
If you are an existing PRADO 3.x user and would like to learn what enhancements are available for each new version, please check out the <a href="?page=GettingStarted.NewFeatures">new features</a> page. Otherwise, the following sections are helpful for newbies.
</p>
+<!--
<div class="start-page">
<div class="concepts start-block">
<h2>How PRADO Works</h2>
@@ -44,7 +45,7 @@ If you are an existing PRADO 3.x user and would like to learn what enhancements
</ul>
</div>
</div>
-
+-->
<p id="10002">
You may refer to the following resources if you find this tutorial does not fulfill all your needs.