Activity Forums Salesforce® Discussions How to Remove Enter Functionality from InputFields in a Salesforce Visualforce Page?

  • Manpreet

    Member
    April 26, 2018 at 4:38 pm

    Hi pranav,

    Add the following script to your Visualforce Page:

    <script type='text/javascript'>
    function stopRKey(evt)
    {
    var evt=(evt) ? evt : ((event) ? event : null);
    var node=(evt.target)?evt.target:((evt.srcElement)?evt.srcElement:null);
    if ((evt.keyCode == 13) && (node.type=="text")) {return false;}
    }

    document.onkeypress = stopRKey;
    </script>

    Thanks.

  • Aman

    Member
    April 26, 2018 at 8:45 pm

    Hi Pranav,

    I have tried the below java script code in all the input fields and Command Button to avoid Enter functionality while creating the opportunity in my own visual force page.It is working very well for me.

    onkeydown="if(event.keyCode==13){this.blur();actionFunction();}"

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos