form won't submit when I press "enter" key

578
1
Jump to solution
02-25-2014 06:48 AM
GyeyoungChoi
New Contributor II
Hi all,

so here is my form with search field and button
<form onsubmit="doFind();">    <button data-dojo-type="dojox/mobile/Button" onClick="doFind();" class="findButton"  value="Search" id="buttonSearch"/>Search</button></form>


however all I can do is click the button to execute it won't work when I press enter when cursor is in the input box.
Plus sometimes key pads tend to work as navigation not number "whether num lock is on or off"
on chrome FF IE all work like that

Do anyone know what's going on? Thanks,

Jack
0 Kudos
1 Solution

Accepted Solutions
JakeSkinner
Esri Esteemed Contributor
Hi Jack,

In your JavaScript code, try adding the 'keyup' event to fire the doFind function when you click enter (keyCode 13).  Ex:

require([   "dojo/on", ...  ], function(on, ... ) {   on(dom.byId("buttonSearch"), "keyup", function(event){        if (event.keyCode == 13) {                 doFind();        }    })   ... });

View solution in original post

0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Jack,

In your JavaScript code, try adding the 'keyup' event to fire the doFind function when you click enter (keyCode 13).  Ex:

require([   "dojo/on", ...  ], function(on, ... ) {   on(dom.byId("buttonSearch"), "keyup", function(event){        if (event.keyCode == 13) {                 doFind();        }    })   ... });
0 Kudos