I'm wondering if it's possible for an input box to have the following properties:
- You can type into the input box... However, whatever you type is not visible to the user
- Whatever was typed into the input box can be read by jQuery via the .keyup function.
- You can detect when the input box has lost focus.
- No Carat in the textbox
For a concrete example:
HTML:
<input type="text" name="magicalBox"> jQuery Code:
$('input[name=magicalBox]').keyup(function(event){ console.log("[1] Received " + String.fromCharCode(event.keyCode)); } $('input[name=magicalBox]').blur(function(){ console.log("[2] No Longer Using Magical Box"); } Ideal: I type 'a' into magicalBox, but I do not see 'a' in magicalBox. However, in my console I will see the [1] message. When i click out of magicalBox, I get the [2] message.
What I've Tried:
- I can get 2 & 3 by setting magicalBox.val('') in the jQuery function, but there is a slight blip where you can see the inputted text.
- Marking magicalBox as readonly seems to help get 1 2 3, but getting 4 seems tough. From what I can see online, the way to hide the carat is to set onfocus="this.blur()", but this stops me from doing anything to the box.
Any advice would be greatly appreciated (... if this is even possible...)