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?
|
 |
 |
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 |
 |
 |
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.
|
 |
 |
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."
|
 |
 |
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 |
 |
 |
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.
|
 |
 |
|