0

When i use below javascript which disables all alphabets, so not able to use Ctrl+A .. help is appriciated

<script type="text/javascript">
 function validate(key) {
      var keycode = (key.which) ? key.which : key.keyCode;
     var phn = document.getElementById('Textbox6');
     if (!(keycode == 8 || keycode == 46) && (keycode < 48 || keycode > 57)) {
         return false;
     }
     else {
       if (phn.value.length < 10) {
             return true;
         }
         else {
             return false;
         }
     }
 }
</script>
Joseph
  • 12,678
  • 19
  • 76
  • 115
sameerag
  • 37
  • 1
  • 2
  • 14
  • possible duplicate of [Best cross-browser method to capture CTRL+S with JQuery?](http://stackoverflow.com/questions/93695/best-cross-browser-method-to-capture-ctrls-with-jquery) - That shuold give you a clue to adjust your if statement – Valamas Oct 10 '13 at 04:55

1 Answers1

0

See here How to detect Ctrl+V, Ctrl+C using JavaScript?

you will found how to detect ctrl+a key and then when user press that one you wrtie return true

i hope this will help you give me feedback is that working? regards...:)

remember

65

is key a's code

[UPDATE]

function validate(key) {
     var ctrlDown = false;
     aKey = 86;
       var ctrlKey = 17;
      var keycode = (key.which) ? key.which : key.keyCode;
     var phn = document.getElementById('Textbox6');
      if (keyCode == ctrlKey)
      {
       ctrlDown = true;
       }
       if(ctrlKey && (keycode==aKey))
       {
        return true;
       }
     if (!(keycode == 8 || keycode == 46) && (keycode < 48 || keycode > 57)) {
         return false;
     }
     else {
       if (phn.value.length < 10) {
             return true;
         }
         else {
             return false;
         }
     }
 }
Community
  • 1
  • 1
Just code
  • 13,553
  • 10
  • 51
  • 93