Expand my Community achievements bar.

Interactive form - drop-downs?

Avatar

Level 8

Hello

I put a drop-down field (its lables is COUNTRY OF VISITOR ) on the interactive form (my_form_of_visitor_info) and bound it to a data source, which data source is passing USA, UK, fine, working well. It should always ALLOW only 3 characters max. length

I also gave a ability to modify/input end-user own value in this drop-down field by checking  "Allow Custom Text Entry" box of the field tab of the object palette, fine.

To accommidate all the label(COUNTRY OF VISITOR) of the field, i gave the WIDTH as 5 inches.

But, now user is entering CANADA, but It should always ALLOW only 3 characters max. length. I did not see any MAX.CHARACTERS ALLOWED feature for the drop-downs as like TEXT FIELDS!

Pls. let me know, How can i get it done this rquirement that systsem should allow ONLY 3 characters in this field? I saw some VALIDATION PATTERN for Zipcode, Tele #..but, i am not sure can i use it for my drop-down field? if so, How?

Thank you

5 Replies

Avatar

Level 4

Hello Srinivas,

You can allow maximum three characters within the dropdown list

i.e after selecting a value from the drop down, the drop down field will contain

the value of three letters, by writing the following script in "FormCalc" language of "exit" event

DropDownList1.rawValue = Left(DropDownList1.rawValue, 3);

Hope it will help you,

Thanks,

Debadas.

Avatar

Level 8

Thank you.

Actually, Don't we have any SETTINGS at form level? I guess, this (Validation Pattern - ZipCode, Tele #) may helps us? Only option is we have script?

2) If so, also pls. let me know the script in Java, bcz am writing Java and am beginner in it

Thank you

Avatar

Level 4

Hello Srinivas,

Sorry there is no setting at form level in case of drop down.

So the only option is scripting.

And the only option is we can do this in "FormCalc" language

because we have to perform the string operation into the item value.

So by using the Left( ) string function, this is possible.

Thanks,

Debadas.

Avatar

Level 8

Okay, Thank you.

1) By chance, do you have any idea about thse VALIDATION PATTERN? this feature MUST applies only to Zipcode & tele #'s?

2) Pls. let me know, is ur script does not hv any syntax errors? bcz, am beginner, its taking long time for me to find a simple mistake like Comma missing! if not, pls. let me know syntax error free script


DropDownList1.rawValue = Left(DropDownList1.rawValue, 3);

Thanjk you

Avatar

Level 7

For javascript you can also use:

var str = this.rawValue;

this.rawValue = (str.substring(0,3));

on the exit event of the drop down list. It simply returns the first 3 chars of whatever gets typed into the field.