views:

40

answers:

2

Hi my dear friends:
I know how can we use onkeyup event of an element...
but I want to have an alert in all of my form areas when a client presses the enter key(for example) (not on an unique element)

Is there a function that already exists in javascript to do this? Should I create a function to do this? Or should i put alert code (with nested if statements) in javascript area code without using a function?
That was my #1 question..

My #2 question is:

I know differences about key events in ie and firefox and ...(keycode and charcode and ...) What is the best way for using key events for ie and firefox for detecting upper situation that i explained?

Thanks in advance!

A: 

2. Question:

With this script you can detect upper/lower case:

<script type="text/javascript">


    function isUpper(String)
    {
        if(String.charCodeAt(0) > 64 && String.charCodeAt(0) < 91)
            return true;
        else
            return false;
    }

    if(isUpper("A"))
        alert("upper case");
    else
        alert("lower case");

</script>
Xarem
really really thanks for your answer / i really apologize for (upper case) in my question...my meaning was the UPPER SITUATION THAT I EXPLAINED....
LostLord
A: 

Answer to you first question :

more about keystrokes : Detecting keystrokes

Example to disable enterkey on press

<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>
Pranay Rana
really really thanks / question # 1 solved ?can u lead me for #2!
LostLord
refer the link "Detecting keystrokes" hope that will help you
Pranay Rana