Expand my Community achievements bar.

Is there any good guy than SEARCH......... that finds EXACT word (only need to check USA as a WORD)

Avatar

Level 8

Hello,


I have a bunch of fields on my_form, just for example here in this posting I am using COUNTRY names ....., just for example,

I have 4 fields (text, dropdown, check boxes), their names (not values, below are NAMES itself) are as below

1) USA,

2) GERMANY

3) USA_ILANDS (under score is there)

4) FRANCE

Well

I placed a hidden a text field, its name is GFL (i mean, Grey Fields List), am using this GFL (field / its data) for my programming purpose

From the back end (in our case, its an ERP -SAP) am populating / filling this GFL field, say for example.... its data looks like,

FRANCE USA_ILANDS (i mean, am concatenating the country names with a seperation of a space)

( FYI.....Already i have some JS piece in my_form INITIALIZATION and docReady events for some other purposes)

Now, my requirement is: Check whether the country name is present in the string data of GFL,

if yes (example, USA_ILANDS)....greyed out it with readOnly

if not (example, GERMANY)....dont touch it / skip the above piece of JS, (I mean, no grey, no readOnly)

I am achieving this requirement by below JS in the INITIALIZATION event of USA field,


My expectation is:

As the USA is not part of the GFL string data (not present).....it should NOT greyed out on the form.............but its greying out in reality.....bcz...the above JS's SEARCH is checking the GFL for USA........and its found in USA_ILANDS in the GFL's data.......hence retruning a value of "true".......and greying out......hmmmmm

Pls. let me know how to fix this issue?

is there any good guy than SEARCH......... that finds EXACT word (only need to check USA as a WORD)

Some expert suggested the below JS for some other purpose, is it helps me, i mean, is the below JS fixes my issue?


Thank you

1 Reply

Avatar

Level 8

I also used the below JS, but no use!

var myStateName = new RegExp("USA");

So, after Google i found the below link

http://stackoverflow.com/questions/447250/matching-exact-string-with-javascript

and am following the first suggested option with place holders like, var r = /^a$/ its working fone for me

Pls. let me know is this is safe? ok? recommendabale? or Any other help to find out exact match word?

Thank you