[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

ASP.NET C# 3.5 Web Application:- PASSWORD text box need to alert on focus if the end-user client machine keyboard CAPS LOCK ON

Posted on 2011-10-13
2
Medium Priority
?
859 Views
Last Modified: 2012-05-12
Hi,

    I am working with ASP.NET C# 3.5 Web Applications.

    My Requirement is:

    Let we say, the end-user / client machine keybord CAPS LOCK is in ON mode. Now the user clicks inside the PASSWORD text box in my web application (i.e.) PASSWORD textmode textbox getting focus. An alert / tooltip message need to dispaly like "CAPS KEY ON".
0
Comment
2 Comments
 
LVL 9

Accepted Solution

by:
TonyReba earned 1000 total points
ID: 36962327
You need to use Javascript ,
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function checkCapsLock( e ) {
 var myKeyCode=0;
 var myShiftKey=false;
 var myMsg='Caps Lock is On.\n\nTo prevent entering your password incorrectly,\nyou should press Caps Lock to turn it off.';

 // Internet Explorer 4+
 if ( document.all ) {
  myKeyCode=e.keyCode;
  myShiftKey=e.shiftKey;

 // Netscape 4
 } else if ( document.layers ) {
  myKeyCode=e.which;
  myShiftKey=( myKeyCode == 16 ) ? true : false;

 // Netscape 6
 } else if ( document.getElementById ) {
  myKeyCode=e.which;
  myShiftKey=( myKeyCode == 16 ) ? true : false;

 }

 // Upper case letters are seen without depressing the Shift key, therefore Caps Lock is on
 if ( ( myKeyCode >= 65 && myKeyCode <= 90 ) && !myShiftKey ) {
  alert( myMsg );

 // Lower case letters are seen while depressing the Shift key, therefore Caps Lock is on
 } else if ( ( myKeyCode >= 97 && myKeyCode <= 122 ) && myShiftKey ) {
  alert( myMsg );

 }
}
//  End -->
</script>

Open in new window

0
 

Author Closing Comment

by:chrisdtrinityphysicians
ID: 36962881
Fine solutions. Thanks.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses
Course of the Month19 days, 20 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question