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 -> PHP

 Another text validation question

Print topic Send  topic

Author Message
bigtoe

Posts: 115
Posted: 09/10/2004, 3:09 AM

Is it possible to do validation on 10-character text
field by comparing it to a database table column which
contains various 10-character text strings?

If yes, how can I do this in CCS?


View profile  Send private message
fsibaja


Posts: 10
Posted: 09/11/2004, 11:27 PM

Your question isn't too clear, could you explain yourself with more detail?.
_________________

Fernando Sibaja
View profile  Send private message
bigtoe

Posts: 115
Posted: 09/12/2004, 12:51 AM

Ok. Here is an example.

I have field called "Shade".
It accepts a text string of 10 characters maximum.

Today, the user enters the text "Orange" in this field.

I want to compare this text to all the values
that exist in rows of
a column called "C_Colors"
in a table called "T_Rainbow"

Today, under "C_Colors" we have:
"Red"
"Blue"
"Purple"
"Black"

Yesterday, under "C_Colors" we had:
"Pink"
"Green"
"Orange"
"Red"
"Magenta"
"White"
"Purple"


Therefore, today "Orange" would fail the validation.
But yesterday, "Orange" would pass the validation.

As you can see - the validation criteria change daily.
I would like the validation to be database driven.


View profile  Send private message
bigtoe

Posts: 115
Posted: 09/12/2004, 1:00 AM

Because the validation failed today,
I would like to display the message
"Shade not found in the database."
View profile  Send private message
Don Safar
Posted: 09/12/2004, 8:28 AM

Why not make it a list control and populate by selecting the distinct values
from T_Rainbow (i.e. select distinct C_Colors,C_Colors from T_Rainbow Order
by C_Colors). This will keep the user from having to guess what colors are
available by being able to select only from the colors in the database.

"bigtoe" <bigtoe@forum.codecharge> wrote in message
news:54143fff2da655@news.codecharge.com...
> Ok. Here is an example.
>
> I have field called "Shade".
> It accepts a text string of 10 characters maximum.
>
> Today, the user enters the text "Orange" in this field.
>
> I want to compare this text to all the values
> that exist in rows of
> a column called "C_Colors"
> in a table called "T_Rainbow"
>
> Today, under "C_Colors" we have:
> "Red"
> "Blue"
> "Purple"
> "Black"
>
> Yesterday, under "C_Colors" we had:
> "Pink"
> "Green"
> "Orange"
> "Red"
> "Magenta"
> "White"
> "Purple"
>
>
> Therefore, today "Orange" would fail the validation.
> But yesterday, "Orange" would pass the validation.
>
> As you can see - the validation criteria change daily.
> I would like the validation to be database driven.
>
>
>
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

fsibaja


Posts: 10
Posted: 09/12/2004, 2:56 PM

Don Safar is right, you should use a listbox instead of a textbox, but you should also do the validation..

Let's say that your table of C_COLORS has 3 columns. ID_COLOR, COLOR_DESC, TODAY_COLOR.
Let's say that TODAY_COLOR column tell us if the color is valid for today.

On your record you could add a on validate event, and add some code like this:
//------------
global $myDB;
global $myRecord;

$id_color = (int)$myRecord->myListbox->GetValue();

$myDB->query("SELECT ID_COLOR FROM C_COLORS WHERE ID_COLOR=$id_color AND TODAY_COLOR=TRUE");

if(!$myDB->nextRecord()){$myRecord->Errors->addError("not a valid color for today, please don't try to cheat me!!!!")}

$myDB->close();

//-------------

I hope this help you.
_________________

Fernando Sibaja
View profile  Send private message
bigtoe

Posts: 115
Posted: 09/12/2004, 4:39 PM

I agree with both of you.
I could use a listbox control.
Actually, I already tried that before.

But the number of (unique) rows under "C_Colors" were
so many that the users were complaining that the
vertical scrolling on this listbox was a pain.
So I decided to take this approach.

I will try the validation as suggested by F.Sibaja.
If you have more suggestions, I am happy to listen.

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.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


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