These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Field Value - YES or NO only

ebbo1983
Registered: Mar 16 2009
Posts: 93
Answered

Hello,

need help with a field. the field in question is called owned_t1.

owned_t1 should show the text "YES / NO" if description_t1 has a value. otherwise owned_t1 should remain blank.

The user should then have the option to edit "YES / NO" and enter "YES" or enter "NO" any other text entry should be rejected and returrned back to "YES / NO". A message popup box would be nice if the user entered a value other then "YES" or "NO"

Can someone help me with this?

so far i have (in calculate)

if (HasValue(description_t1)) then
owned_t1 = "YES / NO"
else
owned_t1 = ""
endif

but whenever i enter any details into the field it returns back to "YES / NO" i need a way for the user to overwrite this with the values "YES" or "NO" but not allow the user to enter any other text.

My Product Information:
LiveCycle Designer, Windows
madhu_livecycle
Registered: Jun 23 2009
Posts: 13
Hi ebbo1983,

to make the field accessble and readonly as you have your script which is checking the Hasvalue

by adding one line in the if case which becomes

if (HasValue(description_t1)) then
owned_t1 = "YES / NO"
owned_t1.access = "open"
else
owned_t1 = ""
owned_t1.access = "readOnly"
endif

will make the field readonly and accessible.


for the field owned_t1 write the below script in Exit Event Script Language as Javascript

if ( !(this.rawValue == null) )
{

if ( !(this.rawValue == "yes" || this.rawValue == "YES" || this.rawValue == "no" || this.rawValue == "NO") )
{
xfa.host.messageBox("please enter valid value either yes or no");
xfa.host.setFocus(form.owned_t1);
}
}

note: owned_t1 is the field name and form is the body page name in the Hierarchy tab which you give.

Thanks,
Madhu.
ebbo1983
Registered: Mar 16 2009
Posts: 93
Hello Madhu, thanks for your help so far.

I am not getting this to work, see my screenshot.

I have put:

if (HasValue(description_t1)) then
owned_t1 = "YES / NO"
owned_t1.access = "open"
else
owned_t1 = ""
owned_t1.access = "readOnly"
endif

in the calculate event of owned_t1 (formcalc)

and

if ( !(this.rawValue == null) )
{

if ( !(this.rawValue == "yes" || this.rawValue == "YES" || this.rawValue == "no" || this.rawValue == "NO") )
{
xfa.host.messageBox("please enter valid value either yes or no");
xfa.host.setFocus(xfa.resolveNode("form1.table1_rows.owned_t1"));
}
}

in the exit event of owned_t1 (JAVASCRIPT)

http://docs.google.com/View?id=dcj7tdvs_25hchdftdm

any more advice?
ebbo1983
Registered: Mar 16 2009
Posts: 93
Finally figured it out:

----- form1.table1_rows.owned_t1::docReady - (FormCalc, client) ------------------------------------

if (HasValue(form1.table1_rows.description_t1)) then
owned_t1.rawValue = "YES / NO"
owned_t1.access= "open"
endif

----- form1.table1_rows.owned_t1::exit: - (FormCalc, client) ---------------------------------------

if (owned_t1.rawValue == "yes" | owned_t1.rawValue == "no" | owned_t1.rawValue == "YES" | owned_t1.rawValue == "NO")
then
owned_t1.access = "open"
else
$host.messageBox("Please enter a valid value - either yes or no")
$host.setFocus("xfa.form.form1.table1_rows.owned_t1")
endif

obviously the first part is not required for most people, if you are doing a simple yes or no then the bottom script should be good enough!