javascript - Prevent default action -
this page open in newwindow. have 1 text box , 2 button(h:commandbutton , a4j:commandbutton).
i move(set) cursor focus textfield.
my problem is, hit enter button textfield, automattically called h:comandbutton action , close new window. how avoid this.
but, need , when hit enter button, move cursor focus a4j:commandbutton
<f:view> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <script type="text/javascript"> function a4jbuttonclick() { alert("a4j command buton clicked..."); } </script> </head> <body> <h:form id="sampleform"> <rich:panel id="samplepanel"> <h:outputtext value="user name : "/> <h:inputtext/> <h:commandbutton value="closing-commandbutton" onclick="javascript:window.close();return false;"/> <a4j:commandbutton value="a4jcommandbutton" onclick="a4jbuttonclick()"/> </rich:panel> </h:form> </body> </html> </f:view>
if hit enter button textfiled, want call script alert("a4j command buton clicked...");
help me. thank in advance.
try add return false in onclick handler:
<h:commandbutton value="hcommandbutton" onclick="hbuttonclick();return false;"/> <a4j:commandbutton value="a4jcommandbutton" onclick="a4jbuttonclick();return false;"/>
but form not submitted when press buttons.
Comments
Post a Comment