JSF Disable Enter key on h:inputText......

Hello All,
Hope all of you are doing good. Currently we are using JSF 1.1 for our new application, i have got a requirement as follows. This is a weird problem i hope....
I have a <h:inputText....> component in my page and when if user presses "Enter" key the page is getting submitted. I have tried by adding the following lines of Javascript code but still it is not working. Could you please review and suggest me on this.
function kH(e) {
     var pK = e ? e.which : window.event.keyCode;
     return pK != 13;
document.onkeypress = kH;
if (document.layers) document.captureEvents(Event.KEYPRESS);
Any suggestions are really appreciated. Thanks in advance.

Try this and see how it works for you:
<script language="JavaScript">
function disableEnterKey(e)
     var key;
     if(window.event)
          key = window.event.keyCode;     //IE
     else
          key = e.which;     //firefox
     if(key == 13)
          return false;
     else
          return true;
</script>
<h:inputText onkeypress="return disableEnterKey(event)" />

Similar Messages

  • Disable ENTER KEY on text item

    All,
    I am trying to disable SUBMIT on ENTER KEY for a text item on a page as below but still its submitting how can i achieve this.
    I want the page to totally disable the enter key so when i press ENTER KEY nothing happens,
    what i did:
    1. when page loads,
    $("input").keypress(function evt) {
    var charCode = evt.charCode || evt.keyCode;
    if (charCode  == 13) {
    return false;
    2.
    Submit when Enter pressed
    NO
    APEX 4.2
    thank you.

    Hi,
    Your code is not valid.
    I'm sure it raises errors.
    Place to page JavaScript -> Execute when Page Loads
    $("input,select").keypress(function(e){
    return e.keyCode!==13;
    Regards,
    Jari

  • Problem with disabling "ENTER" key in JTextArea

    Hi,
    I have the following codes to disable the 'ENTER' key in the JTextArea,
    but it does not work. Does anyone know why?
    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    textarea.getKeymap().removeKeyStrokeBinding(enterKey);
    textarea.addKeyListener(new KeyAdapter() {
    public void keyTyped(KeyEvent e) {
    // do something
    Thanks,
    Pin

    I don't know how you mean "disable", but if you are going to ignore the Enter key, then add a KeyListener to the text area, and in the key pressed method, consume() the key event if the VK_ENTER was pressed. That's all, and you don't have to deal with that key binding thingy.
    The other two event types (typed and released) might be ignored, the enter is processed during key press (as it is now, with the default settings).
    The reason is that processing the Enter key (and other such internally understood keys) is done by the peer, but the peer won't get the key event if it's already consumed.
    FYI: Were it a JTextField, consuming the Enter key presses would mean that the field won't fire action events any more. Since text area does not fire action events, therefore it's a non issue.
    FYI2: Consuming the event only blocks the event to be sent to the peer, all the other listeners still get it.

  • Enter key on multiLine InputText

    Is the Enter Key allowed to use to go to the next line to multiLine inputText?

    Hi,
    Yes it's always allowed, however the problem comes when you then try to output it using an outputText, it won't show the line feed as \n is ignored in HTML. You have to use Trinidad's outputDocument component for that.
    Regards,
    ~ Simon

  • How to disable "Enter" key - urgent

    - i have on my site one site password protected. Now i don't want that users cann use Enter key when they write password. Only when the click with mouse. For that i have onClick="..."
    How can i disable only enter key?
    Thanks

    Don't want the user to press the Enter key... who
    thinks up these ideas anyway? It never ceases to
    amaze me.Internet team in one of my early carrer companies were having problems with a search field on their web project... When the user pressed enter they were getting an error, but it worked when they clicked with the mouse.
    So they decided to remove the ability of the user to press enter, rather than figure out what was wrong and fix it... But they couldn't figure out how to disable the enter button either, so they just put red text below the search field asking users to click on the button and not to press enter...
    How the hell do some people get in the door in Software Companies?

  • Disabling ENTER key

    Hi Experts,
    I need to disable the ENTER button (first button in application toolbar, before tcode input box) in one of my custom screen.
    Pl explain me how to disable this button.. Many thanks in advance!!!

    Benu,
    Did you set your own status in your program using set pf-status 'name'.just double click on that and check the options
    Thanks
    Bala Duvvuri

  • Disabling the enter key

    Hi, I have a jsf page that has an <h:inputText> fileld, and whenever I fill it and press enter the form gets submmited. I want to disable the enter key, so that if the user hits enter nothing will happen. This way the form will only be submmited by clicking a button with the mouse.
    Thank you,
    Komyg

    You can use javascript to do this. The merits of using javascript can be saved for another time. Simply put 'javascript disable enter key' in a Google search and you will find what you need. Here is the link at the top of that list:
    http://www.felgall.com/jstip43.htm
    Good luck.

  • Capture enter key press in h:inputtext

    hi,
    i have a h:inputText component in my jsf page. i need to capture the enter key pressed for this component. how can this be done.
    thanks in advance.

    You can use Javascript for this. In the onkeypress event, check if the keycode is 13 (the enter key) and handle accordingly.
    onkeypress="if (event.keyCode == 13) alert('Enter pressed!');"

  • Since upgrading to Firefox 10.0.2 my AVG extension has had to be disabled, as after typing in any web address in the address bar, the enter key had no effect and I could not go to the site without pressing the Reload arrow on right.

    I have recently upgraded Firefox to the latest version 10.0.2. After that I could not enter any website address and press the enter key and get to the website, nor could I select a website from the dropdown list of previously visited websites. The only way I could get there was by pressing the arrow on the right side of the address box (Reload current page). Once I disabled the AVG extension, everything worked normally. As soon as I enabled the AVG extension, it stopped working again.

    Follow these steps for the controls to work:
    # Start > Programs > Mozilla Firefox > Mozilla Firefox
    # Find the “Tools” menu at the top of the browser window and select “Add-ons”.
    # Click on the “Extensions” icon to make sure you’re in the correct option menu.
    # Locate “AVG Safe Search” and click on the containing line to highlight and select the add-on.
    # Click the “Disable” button and close the Add-ons window.
    # Close down any Firefox windows you may have open.
    # That’s It – You’re Done!

  • Why does firefox change fonts when I am trying to download or get help, click and enter keys are disabled why?

    I recently did a clean install of windows7 after returning from Europe and installed Mozilla firefox being fed up with microsoft and google .
    Fire fox seemed to be working ok but 7 out of 10 downloads were failing, and it seemed that every ebsite entered in the address bar turned into a question.
    There was no save shortcut, or paste buttons just a set of to me useless buttons first html, last html, then when I tried to contact help all of a sudden I got a "install fonts" notice and the enter key stopped working,
    and any action key was also disabled without advising me.
    It appears that either Mozilla or someone doesn't want me using firefox.
    I also noticed that the clean disk and other utilities didn't work and that the temp and temp internet folders were empty when I tried to open them but they actually had some 25 megabytes in them when queried as administrator. I also noticed a quick flash reference to Jscript=void,
    and my 32 bit computer suddenly started up as a 64 bit Turion.
    scan and system clean said machine was clean.
    Whats going on here?
    I am not on my machine, I can't contact you on it because the enter button has been disabled by font change.
    Maybe this robot needs some help too!

    Can you undo the system restore?
    Note that using System Restore can cause your Firefox installation to get corrupted because not all files are restored (only files in a white-list), so be cautious with using System Restore.
    *You may lose data in the Firefox profile folder like .js and .ini files pr profiles.ini can be affected.
    *You may need to (re)install software that was affected.
    In case you need to reinstall Firefox then you need to delete the Firefox program folder before reinstalling to make sure that all files get replaced.
    A possible cause is security software (firewall,anti-virus) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox and the plugin-container from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    *https://support.mozilla.org/kb/Server+not+found
    *https://support.mozilla.org/kb/Firewalls

  • JSF Portlet input text enter key submission

    Hi,
    I have a portlet having input text fields and having command action button(hx:commandExButton). But I have a requirment when I presss enter key in the input text fields instead of submitng form, I want submit command action button.
    Could you please give the details. how I will do in JSF Portlets (code snipeet).
    Currently I implemented when user press enter key I am calling java script function and submit the form.
    Thanks

    Firstly: why using IBM's hx:commandButton instead of standard RI h:commandButton?
    Well, pressing [enter] somewhere in a inputfield usually invokes the firstnext button in the form. Doesn't this happen in your form? Or is the "wrong" button being invoked?

  • How can i disable the Enter key in JTextArea?

    How can i disable the Enter key in JTextArea?
    When i press Enter key in JTextArea,I hope JTextArea do nothing.
    Thanks!

    HI, I've the same problem;
    uncle_alice solution works fine, but if I paste in textArea a multi-line text,
    this last results on more lines (rows);
    Isn't possible to avoid this?
    Alternatively, how can I disable cut/copy/paste on TextArea?
    Thank you in advance.
    MargNat
    Message was edited by:
    MargNat

  • JSF 2.0 ajax : Submit form  on Enter key press in h:inputTextarea

    Dear All,
    I am new to JSF 2.0 . Just wanted to submit the form in ajax when a user hits the "Enter": key while typing
    in the h:inputTextarea . I would be very thankful to you guys if you help me out.
    Thanking in advance!

    I found the problem and a solution :-) The missing piece of the puzzle was the id attribute for the form tag. After some debugging of the JSF JavaScript I found the solution.
    The JavaScript function response(request, context) is invoked to handle the server response. Inside this function the doUpdate(element, context) is invoked.
    The doUpdate() function is doing the modification of the DOM. The function doUpdate() is two times invoked for a response. The first time the html elements are updated.
    The second time the view state hidden field is updated or created but only under the following condition:
    Comment in the JavaScript source code of the jsf.js
    //Now set the view state from the server into the DOM
    //but only for the form that submitted the request.If the forms of the both side haven't the same id the form can't be found on the second page.
    In the following way it is working:
    page1.xhtml
    <h:form id="myform">
            <h:commandLink value="Go to page 2" action="page2">
                <f:ajax render="@all" execute="@all"/>
            </h:commandLink>
    </h:form>
    .....page2.xhtml
    <h:form id="myform">
                <h:commandLink value="Go to page 1" action="page1">
                    <f:ajax render="@all" execute="@all"/>
                </h:commandLink>
    </h:form>So always set an explicit id for each JSF tag.

  • Macbook internal keyboard  return/enter key disabled

    Suddenly apropos of no software changes, the enter key has stopped functioning.  Is there a repair or am I going to have to buy a new upper case at $150 plus labor because one key has stopped working?  I have tried an external keyboard and the external return key will work.  The big problem is getting a google search to enter.....
    Thanks for any comments.  Unfortunately,  it seems that this is a hardware problem since I have not had other issues before with keyboard freeze of any kind.

    The genius bar on Michigan Avenue has a stool with my name on it... guess I'll be bellyin' up to the bar again this week.
    Thanks.

  • How to call a method in backing bean on hitting 'Enter' key on a page.

    Hi all,
    I would be obliged if any one can provide me solution for the below given problem.
    My requirement is to call a method in backing bean when i hit 'Enter' key on a JSP page.
    I am trying this by using a script given below.
    *function fnChangeFocus(){*
    *if(window.event.keyCode==13){*
    * document.getElementById("mainform:submitForm:commandbutton").focus();*
    The JSP has the textbox as given below.
    *<h:inputText id="inputtxtboxid" disabled="false" value="#{Bean.inputvalue}"*
    onkeypress="fnChangeFocus()" size="24" />
    Using this I could not acheive the required functionality. Please suggest some alternative.
    Thanks,
    Jagadeesh Pala

    Only a form element supports the submit() function. Make sure that the getElementById returns the appropriate form. Or rather pass the element as the 'this' reference to the function and get the parent form from it.
    After all this is just basic DHTML / Javascript+DOM knowledge and in fact this has nothing to do with JSF. For future basic DHTML / JS+DOM questions you may take a look at the appropriate forums, e.g. dhtmlcentral.com, dynamicdrive.com, etcetera.

Maybe you are looking for

  • How to test a simple PL SQL function from another PL SQL script

    Hi, I have created a function. Now i need to test that whether it is returning the correct values or not. For that, i have written anothe pl sql script and trying to call this function. Im passing all the IN parameters in that function. I assume here

  • Expert help needed to connect iPhone / iPad using BlueTooth and Wi-Fi

    We need expert help to connect iPhone / iPad using BlueTooth and Wi-Fi. If you have worked with Apple MFi Program [http://developer.apple.com/programs/mfi], or have expertise/experience in this, please contact me. Thanks! Kevin.

  • Can't drag-and-drop into applications folder

    Just got a new iMac last week, my old ibook finally died. I'm trying to install firefox in the imac and i can't. It downloads fine, I can open up the .dmg file, but then I can't drag the icon into the applications folder. I can drag it, but nothing h

  • External Display 1440x900 supported?

    Hi folks... Perhaps someone here has direct experience with this, or can do a test with your setup. There's a nice widescreen Samsung LCD monitor with 1440x900 resolution (model number 941BW). Does the external VGA output of a 400/500 MHz TiBook (the

  • Are HDV tapes really necessary? (Last question for now, I promise)

    Do you really need to use them to shoot HD footage? Is there an obvious benefit to them or is this another marketing thing?