I'm sure that this script will help you in some of your projects that needs a username and password.
Sometimes when we want access to a secure page that asks for a username and password and we submit the information but we didn't know that the password was submitted in upper case, we get an error.
Solution:
jQuery('#username').keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) { jQuery('#capslockdiv').show(); } else { jQuery('#capslockdiv').hide(); } }); jQuery('#password').keypress(function(e) { var s = String.fromCharCode( e.which ); if ( s.toUpperCase() === s && s.toLowerCase() !== s && !e.shiftKey ) { jQuery('#capslockdiv').show(); } else { jQuery('#capslockdiv').hide(); } });
Sample HTML code