how to detect keyboard layout js 1

how to detect keyboard layout js

function checkKeyboard(ob,e){
        re = /\d|\w|[\.\$@\*\\\/\+\-\^\!\(\)\[\]\~\%\&\=\?\>\<\{\}\"\'\,\:\;\_]/g;
      a = e.key.match(re);
      if (a == null){
        alert('Error 2:\nNon English keyboard layout is detected!\nSet the keyboard layout to English and try to fill out the field again.');
        ob.val('');
        return false;
      }
      return true;
    } 

Here is what the above code is Doing:
1. It's checking if the user is using a non-English keyboard layout.
2. If the user is using a non-English keyboard layout, it's alerting the user to change the keyboard layout to English.
3. It's also clearing the field that the user is typing in.

Similar Posts