CodeCharge Studio
search Register Login  

Visual Web Reporting

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

YesSoftware Forums -> CodeCharge Studio -> Tips & Solutions

 Error message with a link to the wrong field

Print topic Send  topic

Author Message
graziano

Posts: 3
Posted: 02/20/2008, 9:15 AM

Hi, i'm a newbie to CCS.
I needed a message box with something more verbose than the field name:
"The field AC001B2 is not valid."
Maybe some other has a better solution, i made just a fast search in the forum and found nothing right for me.
I suppose to have a grid with in the first column the label and in other columns the input fields.

You have something like this:

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

Change to
<!-- BEGIN Error -->
<tr class="Error">
<td id="ERRORE" colspan="2">{Error}</td>
</tr>
<!-- END Error -->

As I'm italian I use the id ERRORE (error) so don't conflict with anything else and so for the function name errori (errors).


<body onload="errori();">


in head

<script>
function errori() {
var c = 0; // the label's column
if (document.getElementById("ERRORE")) { // we have an error !
IHE = document.getElementById("ERRORE").innerHTML; // error message
a = document.getElementById("ERRORE").innerHTML.split("field "); // get error lines
for (i = 1;i < a.length; i++) {
b = a.split(" ")[0]; // get field name
e = document.getElementsByName(b)[0]?document.getElementsByName(b)[0]: document.getElementsByName("f_"+b)[0]; // in my application CCS add "f_" before field name
EIH = "<A name='"+b+"'>" + e.parentNode.innerHTML; // make an anchor
t = e.parentNode.parentNode.getElementsByTagName("td")[c].innerHTML; // get the label
e.parentNode.innerHTML = EIH; // insert the anchor in html before the field;
re = new RegExp(b,"ig"); // create a regexp
IHE = IHE.replace(re, "<A href='#"+b+"'>"+t+"</a> "); // insert a link with the field's label
}
// i write the message in Italian, you can do anything you want
IHE = IHE.replace(/The value in field/gi, " "); // delete The value in
IHE = IHE.replace(/is not valid/gi, " NON VALIDO!<br>"); // change is not valid to NON VALIDO
//
document.getElementById("ERRORE").innerHTML = IHE; // replace with the new error message }
}

</script>



View profile  Send private message
datadoit
Posted: 02/20/2008, 10:21 AM

Good stuff!
DonB
Posted: 02/22/2008, 8:38 AM

Or, you can add an 'error' Label for each text field. Designate it as the
"Error Control" then the error text will be stuffed in there instead of one
for the grid/record as a whole. Utilize the before show event on that label
to edit the error text so it's more friendly, or just give the label an
appropriate CSS style.

--
DonB



"graziano" <graziano@forum.codecharge> wrote in message
news:2547bc60222a716@news.codecharge.com...
> Hi, i'm a newbie to CCS.
> I needed a message box with something more verbose than the field name:
> "The field AC001B2 is not valid."
> Maybe some other has a better solution, i made just a fast search in the
> forum
> and found nothing right for me.
> I suppose to have a grid with in the first column the label and in other
> columns the input fields.
>
> You have something like this:
>
> <!-- BEGIN Error -->
> <tr class="Error">
> <td colspan="2">{Error}</td>
> </tr>
> <!-- END Error -->
>
> Change to
> <!-- BEGIN Error -->
> <tr class="Error">
> <td id="ERRORE" colspan="2">{Error}</td>
> </tr>
> <!-- END Error -->
>
> As I'm italian I use the id ERRORE (error) so don't conflict with anything
> else
> and so for the function name errori (errors).
>
>
> <body onload="errori();">
>
>
> in head
>
> <script>
> function errori() {
> var c = 0; // the label's column
> if (document.getElementById("ERRORE")) {
> // we have an error !
> IHE = document.getElementById("ERRORE").innerHTML; // error
> message
>
> a = document.getElementById("ERRORE").innerHTML.split("field "); // get
> error lines
> for (i = 1;i < a.length; i++) {
> b = a.split(" ")[0]; // get field name
> e = document.getElementsByName(b)[0]?document.getElementsByName(b)[0]:
> document.getElementsByName("f_"+b)[0]; // in my application CCS add "f_"
> before field name
> EIH = "<A name='"+b+"'>" + e.parentNode.innerHTML; // make an anchor
> t = e.parentNode.parentNode.getElementsByTagName("td")[c].innerHTML; //
> get
> the label
> e.parentNode.innerHTML = EIH; // insert the anchor in html before the
> field;
> re = new RegExp(b,"ig"); // create a regexp
> IHE = IHE.replace(re, "<A href='#"+b+"'>"+t+"</a> "); // insert a link
> with
> the field's label
> }
> // i write the message in Italian, you can do anything you
> want
> IHE = IHE.replace(/The value in field/gi, " "); // delete The value in
>
> IHE = IHE.replace(/is not valid/gi, " NON VALIDO!<br>"); // change is not
> valid to NON VALIDO
> //
> document.getElementById("ERRORE").innerHTML = IHE; // replace with the
> new
> error message }
> }
>
> </script>
>
>
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.yessoftware.com/
>

graziano

Posts: 3
Posted: 02/22/2008, 2:01 PM

As told I'm a newbie, I tried this but I am working (not my choice!) on forms with more than 300 fields, is there a sure and fast way to modify the template? Also i need a very visible warning on the top of the form.
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.