Masked Input Plugin 1.1.2
I just released version 1.1.2 of my Masked Input Plugin for jQuery. Felix Geisendörfer helped me mash out a few things with this release. He fixed the bug for Mac/Firefox with the backspace key and got me to open up the caret positioning functions. Thanks Felix!
Here are the changes for this release
- Fixed a bug in Mac Firefox with backspacing.
- Fixed a bug where delete at end of mask produced an extra placeholder character.
- Exposed the caret positioning and retrieval methods as a jQuery function extension. You can now call $().caret() to get a caret position and $().caret(start [,end]) to set a caret position.
Thank you. I never make a project without his plugin.
keypressEvent returns false, this prevent onchange to be called (at least in FF).
this code force onchange to be triggered.
….
$(’#’ + this.id).change();
return false;
Love the masked input plugin. I had a need to set an upper case mask, but it should let people type in lowercase and the upcase the letters for them, so this is what I did.
Created an upcase charmap at line 65:
‘A’:”[A-Za-z]”
Change the value of k before line 173 if the mask is ‘A’:
if(mask.charAt(p) == ‘A’ && k>=97 && k<=122){
k -= 32;
}
buffer[p]=String.fromCharCode(k);
Thanks for creating the plugin!
Great thing!
But I’ve got two requests:
1. to add an input type “numeric with separator” to accept ‘.’ and ‘,’ and covert them to any one of them;
2. to add support fo function keys in FF - F5 to reload page etc.
How do i specify optional blocks of the mask, e.g. “ZIP + 4″?
Example: /^\d{5}(-\d{4})?$/ = 33701-4313 or 55416
Same thing here ! I’d like to have a mask to check currency values, it means something like 9999,99 € or 9.99 €. Do you have any idea about that ?
Is it possible to put the cursor on the begin of an input field, and not at the end? So the user can start edit the values without first deleting the old content? Thanks!
Would be great if we could have an “modifier” for the mask to specify that mask applies to all chars of the input field. For a 50 chars length field it could be:
$(”#name”).mask(”@a”);
instead
$(”#name”).mask(”aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa”);
To uppercase use a style in your input:
text-transform: uppercase;
To put the cursor on the beginning alter line 113 to:
$(input[0]).caret(firstNonMaskPos);
Humm… the text-transform style change only the display not the content
I’m getting trouble with del and backspace keys. They don’t work properly. Anyone have this issue?
does this only work with release 1.1.2 of jquery?
and do i need to download any more than the core jquery?
using just the core of the latest release seems not to work for me
thanks!
I also need a way to use mask on currency fields,
My field is like :
R$ 999.999.9 …. 99,99
The length of chars in this case is unlimited
do u have any idea about how am I going to make that ?
Thanks in advance
For those looking for a mask on currency fields, I found an example on the following page
http://inovaideia.com.br/maskInputMoney/
Hello, very nice plugin, but needs a few tweaks to make it perfect.
Make distinction by (for required):
“text” > “T” (all w/o numbers)
“numeric” > “N” (numbers)
“all” > “A” (all)
and for NOT REQUIRED small caps:
“text” > “t”
“numeric” > “n”
“all” > “a”
* it is very very important that TEXT (T or t) is ALL BUT NUMBERS, so that the plugin could be used in many languages without any problems (all non A-Z: “{}[]!”#$%&/()=?*ŠĐŽČĆ” CAN BE USED FREELY if “T” or “t” is chosen). Users can define their own sets, but this should be standard.
IE.
AAA (NNN) TTTttt
First three A’s are capitalized, which means they are required, all allowed. In the “()” N’s are capitalized which also means they are required and numbers only. Then we have “TTTttt”, first three are ALL BUT NUMBERS (text characters no matter which language or “{}[]” is ok) and are required, second three are not required.
If you manage to tweak plugin to do this, it will be jaw dropping!!!
Great idea, that’s for sure.
Hope you’ll make the changes, and use 100% of the plugin’s potential.
This plugin rules. Thanks a million!!!!!
I had a really good look at doing the optional/required thing but it cannot work when you are checking each keypress.
i.e. check inputchar(i) against maskchar(i)
You would need to match the whole thing against a RegExp at the end.
How much do you offer for completing your suggestion ? milan kalinic.
Where’s your attempt at this work?
Let me guess. You are a manager and not even a coder?
I think it is very cool!