this is something that I did for a friend not to long ago:
jQuery.fn.paste = function(func) {
if (typeof func == "function") {
jQuery(this).each( function () {
if ($.browser.msie) {
this.onpaste= function() {
setTimeout(func+"(this)", 100);
};
$(this).bind('keyup',
function(e) {
func(this);
});
}
else if ($.browser.mozilla) {
this.addEventListener('input',
function() {
func(this);
}, false);
}
});
}
}
it only needed to support FF and IE, so that's what it supports right
now... I don't know if there are similar events for non mozilla
browser that can be added, but you could start with this and see what
you could make of it.
you call it with $(obj).paste(callback), pretty straightforward, the
callback gets passed the object thats changed... hope it helps, oh and
awesome plugin, I might use that in the near future. Thanks!
//Kristinn
On 2/21/07, Jonathan Freeman <[EMAIL PROTECTED]> wrote:
> Very slick plugin, I will for sure use this on my next application. An
> enhancement might be to provide a elegant way of handling non fixed length
> numbers, such as currency inputs. So I guess its not so much masking, but
> pattern matching.
>
> $("#amount").maskedinput("999,999.99");
>
> Nice job!
>
>
>
> --- mrcarxpert <[EMAIL PROTECTED]> wrote:
>
> >
> > So I'm reading that FF, Opera, and Safari support the
> > DOMCharacterDataModified event. I'll try to look into this further to
> > produce something to handle pastes. I've never messed with this event
> > before, so I'm just shooting the dark here. Any direction from the
> > crowd?
> >
> > Josh
> >
> >
> > John Resig wrote:
> > >
> > > This is so awesome. I love how the backspace key forces you into the
> > > correct
> > > space.
> > >
> > > The tricky bit, that I found, is that if you paste in a block of text
> > > (either correct, or incorrect) or if the browser's autocomplete fills
> > in
> > > an
> > > incorrect value it doesn't "correct" it until you hit another key
> > inside
> > > the
> > > field.
> > >
> > > Offhand, I think the best way to "solve" this is to have a
> > > setInterval(...)
> > > check the fields at a specified rate (a couple times a second? or
> > whatever
> > > seems reasonable). This should solve both issues.
> > >
> > > Again, this is really really great, I'll be putting this into place,
> > like,
> > > tomorrow.
> > >
> > > --John
> > >
> > > On 2/13/07, mrcarxpert <[EMAIL PROTECTED]> wrote:
> > >>
> > >>
> > >> Hello everyone. I just wanted to take this opportunity to introduce
> > >> myself
> > >> and start giving back to the community.
> > >>
> > >> I've been using jQuery for about 6 months now, and in the process
> > I've
> > >> produced a few plugins. As I clean up the code in these I will be
> > >> releasing
> > >> them. The first of which is a masked input plugin for
> > dates,SSNs,phone
> > >> numbers, etc.
> > >>
> > >> I've made the source code and examples for this project available at
> > >> http://digitalbush.com/projects/masked-input-plugin
> > >> http://digitalbush.com/projects/masked-input-plugin .
> > >>
> > >> I've tested this in Firefox and IE7 with the latest jQuery library.
> > If
> > >> you
> > >> don't mind I'd like to get some feedback on the plugin and how I can
> > make
> > >> it
> > >> better. I'd also like to know if there are any problems on other
> > >> platforms.
> > >>
> > >> Since this is my first plugin I'm sure I'm missing a few things, but
> > I
> > >> tried
> > >> to follow the patterns from some other plugins on the jQuery site.
> > One
> > >> thing I know I'm missing is, what's the best way to ensure that this
> > >> masking
> > >> is only applied to a text input? Right now my code returns
> > this.each(
> > >> /*code*/), but I'm guessing I might want to
> > >> this.find("[EMAIL PROTECTED]'text']").each(/*code*/). What is the most
> > >> elegant
> > >> way to do this?
> > >>
> > >> Anyway, I look forward to some feedback. I'll consider myself
> > formally
> > >> introduced. :)
> > >>
> > >> Josh
> > >> --
> > >> View this message in context:
> > >>
> >
> http://www.nabble.com/Introduction-and-Masked-Input-Plugin-tf3224850.html#a8957581
> > >> Sent from the JQuery mailing list archive at Nabble.com.
> > >>
> > >>
> > >> _______________________________________________
> > >> jQuery mailing list
> > >> [email protected]
> > >> http://jquery.com/discuss/
> > >>
> > >
> > > _______________________________________________
> > > jQuery mailing list
> > > [email protected]
> > > http://jquery.com/discuss/
> > >
> > >
> >
> > --
> > View this message in context:
> >
> http://www.nabble.com/Introduction-and-Masked-Input-Plugin-tf3224850.html#a8970941
> > Sent from the JQuery mailing list archive at Nabble.com.
> >
> >
> > _______________________________________________
> > jQuery mailing list
> > [email protected]
> > http://jquery.com/discuss/
> >
>
>
>
>
> ____________________________________________________________________________________
> Do you Yahoo!?
> Everyone is raving about the all-new Yahoo! Mail beta.
> http://new.mail.yahoo.com
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/