Hi,
even if you could catch keypress events with WebWidget (javascript), it is problematic to get the ID of the InputField's UI element, and even if you can make it work to catch that event, I don't know how you could then invoke server side events like the ChangeIt() event in the above example.
If you add a WebWidget UI element, and then bind a string context attribute (e.g. let's call it "jscript" in this example) to its "html" property then you can add a code to the wdDoInit() like this:
String jsc = "<html>" + "<head>" + "<script> " + "var myinput = document.getElementById(\"KDDL.New1CompView.InputField\");" + "myinput.onkeypress= function() {" + "alert(\"key pressed\"); }" + "</script>" + "</head>" + "<body>" + "</body>" + "</html>"; wdContext.currentContextElement().setJscript(jsc);
This pops up an altert window any time you press a button on your keyboard when focusing the 1st inputfield, but there are some problems with this.
One is that you have to check the ID of the input field in some http trace tool (this ID was KDDL in my case as you see in the above code BUT this will be different on your end and afaik this ID might even change if you undeploy/redeploy your app again) and as mentioned I am not sure there is any way to proceed from here, i.e. invoke any event like the ChangeIt() event, since that is on server side, and javascript is client side coding.
What you could theoretically do is that you do the entire check and the enabling/disabling of input elements using javascript but this would mean a really painful coding, not to mention the generated html input IDs I pointed out above and which makes all this pretty fragile and error prone.
So all in all I don't recommend to play around with this, rather try to live with the restrictions of webdynpro (it is simply not meant to be used in the way you intend to use). If this project was mine I would rather implement the application in "webdynpro-way" i.e. all the inputfields are enabled and if the customer enters something into the second inputfield (which meant to be filled only when the first is filled) then at submitting the changes (and that triggers a roundtrip) you do the validation and you show an error message that filling the second field expects the first field to be filled as prerequisite.
Or you hide/disable the secondary inputfields and once the form has been submitted you make them visible/editable.
Still I hope this was helpful.
Best Regards,
Ervin