diff options
| author | wei <> | 2007-03-27 08:34:28 +0000 | 
|---|---|---|
| committer | wei <> | 2007-03-27 08:34:28 +0000 | 
| commit | d5950ec0b553d46c4800adc0532d4464a4eb1883 (patch) | |
| tree | 232a4f5ccbd36d6a114dff383adb383793422814 /demos/quickstart/protected/pages/Controls/Samples | |
| parent | cdf3ba1c190393d86460f8c13073dc9784436b3e (diff) | |
Fixed #278, conditional validation.
Diffstat (limited to 'demos/quickstart/protected/pages/Controls/Samples')
4 files changed, 68 insertions, 46 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 | 
