Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jul 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Prevent submit enter key

    hello, i have the following code that catch every time the key enter is press and submit the form, but what i want to prevent is that if i am in a textfield don't submit the form. Is any way to modifed this code to do that? Thank you

    Code:
    document.onkeyup=function(e){
    
    var esIE=(document.all); 
    tecla=(esIE) ? event.keyCode : e.which;
    
    if((tecla==13 || tecla==27))
    {
        var tCol=document.getElementsByTagName('*'); 
        var z=0; 
        for(var i=0;i<tCol.length;i++){ 
       
        	 if(tCol[i].style.zIndex>z && tCol[i].style.display!='none' ){ 
                    z=tCol[i].style.zIndex; 
              } 
         }
    
    	if(z==0)
    	{
    		if(tecla==13){
    			if(validaContinuar())
    			{
    				CAF.model('#{activePageBean.clientIds['hEnter']}').raise();
    			}
    	 	}
    		else if(tecla==27)
    		{
    			CAF.model('#{activePageBean.clientIds['hEsc']}').raise();
    		}
    		}//ifzindez
    	}//ifenteresc
    };

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,763
    Thanks
    23
    Thanked 548 Times in 547 Posts
    Is there any reason why you just don't use the SUBMIT button? It would make your coding life so much easier.
    Evolution - The non-random survival of random variants.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •