Login Register

TextBox, onChange, and the Enter Key

I'm using dijit.form.TextBox controls and I would like the registered onChange function to be called when the user hits the enter key after entering text into the text box. Ideally I'd like to keep the focus in the current element. An acceptable alternative would be to have the control set to the next element in the tabIndex order. Here's a code snippet:

<input type="text" name="xmin" id="xmin" tabIndex=1 onChange="updatePlot(this)"
dojoType="dijit.form.TextBox" />

<input type="text" name="xmax" id="xmax" tabIndex=2 onChange="updatePlot(this)"
dojoType="dijit.form.TextBox" />

<input type="text" name="ymin" id="ymin" tabIndex=3 onChange="updatePlot(this)"
dojoType="dijit.form.TextBox" />

<input type="text" name="ymax" id="ymax" tabIndex=4 onChange="updatePlot(this)"
dojoType="dijit.form.TextBox" />

If the user, for example, enters a value in the 'xmin' textbox and presses the Tab key, then everything works as expected. The onChange function (updatePlot) is called with the correct parameter and focus moves to the 'xmax' textbox. If instead of the Tab key the user presses the Enter key nothing happens.

Searches for this problem keep returning answers about form submission. I don't have a form here--the updatePlot function invokes an ajax call.