CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 How to prevent validation errors from being displayed

Print topic Send  topic

Author Message
jeden


Posts: 20
Posted: 05/17/2006, 4:38 AM

I searched for a solution to this problem in the forums, but I didn't find any.

I have a registration form which uses 2 dependent listboxes Country and State, where State is populated basing on the Country selection.

To dinamically load the State listbox I had to add a client OnChange event to the Country listbox, which submits the form. But at this point the form displays all errors (mainly missing fields) and I don't want this to happen.

This is the solution I found, based mainly on client side javascript:

The name of my form is "RegisteredUser"

1. I have added a Hidden field to the form, with name Validation, Control Source Type = "Code Expression", type Boolean and default value = True

2. I've added a client OnChange event to the Country listbox, with the following code:

document.forms["RegisteredUser"].Validation.value = "No";
document.forms["RegisteredUser"].submit();

3. In the HTML code, I've located the {Errors} row, and set the id and name attributes to "phErrors" - it should look like:

<!-- BEGIN Error -->
<tr class="Error" id="phErrors" name="phErrors">
<td colspan="2">{Error}</td>
</tr>
<!-- END Error -->

4. I've added a client OnLoad event to the form, with the following code:

var phErrors = document.getElementById ("phErrors");

if (phErrors != null)
{
if (document.forms["RegisteredUser"].Validation.value == "No")
{
document.forms["RegisteredUser"].Validation.value = "Yes";
phErrors.style.visibility = "hidden";
phErrors.style.position = "absolute";
}
else
{
phErrors.style.visibility = "visible";
phErrors.style.position = "relative";
}
}

This code reads the value of the "Validation" hidden field: if the value is No, the phErrors row is hidden, otherwise it is shown

It seems to work correctly, and also it shouldn't add the row to the database, because the validation occurs at server side, but it isn't displayed at client side (although included in the HTML)

Antonio
_________________
Antonio Bello

Elapsus - Software & Solutions
http://www.elapsus.com

Developer's Corner
http://www.developer-corner.com
View profile  Send private message
Damian Hupfeld
Posted: 05/17/2006, 4:35 PM

Nice working Antonio.
Have you looked at the Dependant Listboxes by Sixto and updated by Walter?
Search in the PHP forum for Dependant Listboxes or follow this link:

http://forums.codecharge.com/posts.php?post_id=68129

Download from Walters website the CCS3 files and instructions.

Damian

"jeden" <jeden@forum.codecharge> wrote in message
news:25446b0b335bc7c@news.codecharge.com...
>I searched for a solution to this problem in the forums, but I didn't find
>any.
>
> I have a registration form which uses 2 dependent listboxes Country and
> State,
> where State is populated basing on the Country selection.
>
> To dinamically load the State listbox I had to add a client OnChange event
> to
> the Country listbox, which submits the form. But at this point the form
> displays all errors (mainly missing fields) and I don't want this to
> happen.
>
> This is the solution I found, based mainly on client side javascript:
>
> The name of my form is "RegisteredUser"
>
> 1. I have added a Hidden field to the form, with name Validation, Control
> Source Type = "Code Expression", type Boolean and default value = True
>
> 2. I've added a client OnChange event to the Country listbox, with the
> following code:
>
> document.forms["RegisteredUser"].Validation.value = "No";
> document.forms["RegisteredUser"].submit();
>
> 3. In the HTML code, I've located the {Errors} row, and set the id and
> name
> attributes to "phErrors" - it should look like:
>
> <!-- BEGIN Error -->
> <tr class="Error" id="phErrors" name="phErrors">
> <td colspan="2">{Error}</td>
> </tr>
> <!-- END Error -->
>
> 4. I've added a client OnLoad event to the form, with the following code:
>
> var phErrors = document.getElementById ("phErrors");
>
> if (phErrors != null)
> {
> if (document.forms["RegisteredUser"].Validation.value == "No")
> {
> document.forms["RegisteredUser"].Validation.value = "Yes";
> phErrors.style.visibility = "hidden";
> phErrors.style.position = "absolute";
> }
> else
> {
> phErrors.style.visibility = "visible";
> phErrors.style.position = "relative";
> }
> }
>
> This code reads the value of the "Validation" hidden field: if the value
> is No,
> the phErrors row is hidden, otherwise it is shown
>
> It seems to work correctly, and also it shouldn't add the row to the
> database,
> because the validation occurs at server side, but it isn't displayed at
> client
> side (although included in the HTML)
>
> Antonio
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

jeden


Posts: 20
Posted: 05/17/2006, 10:59 PM

Hi Damian,

thanks for the hint - it sounds interesting.... although by now I won't change my solution, since it works :)

Anyway, I will if I need to use it again in my project.

Antonio
_________________
Antonio Bello

Elapsus - Software & Solutions
http://www.elapsus.com

Developer's Corner
http://www.developer-corner.com
View profile  Send private message
roeya


Posts: 181
Posted: 05/18/2006, 1:42 PM

There is also an example of dynamic dependent checkboxes for all languages (Perl etc...) in ExamplePack2
_________________
http://www.infoneto.com/
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.