Did you try...

Did you try...

Did you try the following strategy?

Listen on keypress. If the pressed key is delete or backspace simply store the actual text and the actual key pressed and the actual cursor position (I don't know if there is a way to distinguish from the '.' and the Delete key....)

listen on input. When this happens the text is already changed. Now you can guess what happened from the stored values. It Is similar to the way the paste is managed in FF.

PS: I tried the other script you posted but it doesn't manage paste (Ctrl+V doesn't work and if you right click on the field and select paste on the menu it pastes the text even if wrong)

Nice...

Nice...

...but:

If i understood this plugin right, it is only possible to mask a field for a known length. So if I want to mask it for eMail or a telephone number which length isnt known exactly, it wont work. Right ?

My telephone number may look like:
(+49) 40684
(+49) 805-6568452

So i would be in need of wildcards, something like this:
(+99) 9*
(+99) 9*-9*
or a combination so both a accepted at the same time

It would also be nice if i could give a regular expression for the whole field and not only for a digit, so it would be possible to test for a valid email adress with a regexp like this:

Code:

^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$

Ok, as i m typing and thinking about it, for eMail Adresses masking input didnt seem to be the right way to do it. Maybe its easier to verify the input after its typed. But would be nice if user couldn

What is the wanted behaviour?

What is the wanted behaviour?

Is the following one the wanted behaviour?
Suppose I have a mask to enter an phone number
Now my phone number can be 0123/123456 or 01/12345678
So you write this mask (or something like this):
99X[0-9]*X/999999X[0-9]*X

In the field you initially see:
__/______

Now, if you want to enter 0123/123456, you type the 0 and 1 and you have:
01/______

Now, if you type 2 the mask become
012/______
Now, if you type 3 the mask become
0123/______
Now, if you type 0 the mask become
01230/______

To move after the "/" you have to move using the arrows key, or you have to type /
Correct?

The feature is not implemented, but I don't think it's too difficult to do (look at the injectValue method, and getValidatedKey method... ). I don't have time in this moment, but maybe I will look into this (I have the problem of phone numbers too, but not now...) If you need it now, I accept a patch .
PS: before doing something i will wait for feedback on the wanted behaviour.....

Nice plugin.
However I have found a bug on firefox with linux (works in windows) . If you delete characters in a textfield too fast (When you let your finger on the button, it works otherwise) the mask is also deleted which cause unwanted behavior.
You then need to blur the textfield and refocus so that the mask comes back.

I'll take a look at what could be the cause of it when I'll have some time.

To move after the "/" you have to move using the arrows key, or you have to type /
Correct?

Sounds good Sry that i have no patch for that. By now i m not so good in javascript

I tried to use your plugin with a combobox as "search field". It works well... but if i leave the combobox with a mouse click in another field the typed text vanishes ... Do i have to change something for Combo fields ?

I ll watch this thread maybe i can switch from my vtypes to this plugin at some point...
Nice work!