When you want to check the value of a field in that field's own Keystroke script you need to use event.changeEx property, not access that field value property by using getField(). That returns the previously selected value, not the new one.
Actually, I would use the custom Validation script, instead of the KeyStroke script, and then you just need to access event.value to get the new field's value, and there's no need to check if it will commit.
Hmm, not sure I understand the whole thing. I understand that using getField() is probably the problem because it actually select the previous value, and should use event.changeEx, however I don't know how to do that.
I also like your idea of putting it in Validation, however I don't know (again) how to access event.value. If I change getField("InPatient1").value for example to getField("InPatient1").event.value the console will return me with an error
TypeError: getField("InPatient1").event is undefined
Not sure how to make the changes you recommended.
Replace this.getField("InPatient1") with event. So what was before this.getField("InPatient1").value should now be event.value.
This only applies to the script associated wtih InPatient1, of course.
I removed everything in keystroke, and put the following in the validation of InPatient1
if(event.value == "E078")
this.getField("PremiumCode").display = display.visible;
this.getField("E078Board").display = display.hidden;
this.getField("PremiumCode").display = display.hidden;
this.getField("E078Board").display = display.visible;
but it still behave like before, nothing has changed.
When you use event.value in a combo box's Validate event it does not give you the export value, which is what you want. It is easier to use place the code in a custom Keystroke script where you can use the event.changeEx property to retrieve the export value of the selected item. See the documentation for more information: http://livedocs.adobe.com/acrobat_sdk/9.1/Acrobat9_1_HTMLHelp/JS_API_AcroJS.88.607.html
Just replace the export value with the display value and you should be good
I looked at the link and replaced the export value with the display value, and I still can't get it to work.