My goal was to detect a val() call from within my masked input plugin. So, when someone says "$("#id").maskedinput('(999) 999-9999')" , I would love to be able to detect when that value had been set programatically and then re-check the masking.
So, if someone does a "$("#id").val('555-867-5309')" later on, I could reformat it properly to "(555) 867-5309". Maybe that will shed some light on what my intentions are. Thanks for your quick responses Dan! Josh On Jun 12, 3:30 pm, "Dan G. Switzer, II" <[EMAIL PROTECTED]> wrote: > Josh, > > >One more quick thing, is it possible to attach this to the val() of a > >single input, or am I limited to extending this globally? > > Instead of calling the below method "val" call it something else--like > "valChange()" or something. Then just call that new method any time you want > the change event to be triggered. > > Also, since you're really only wanting to do this for a single field, you > could also just avoid the plug-in and just do: > > $("#myField").val("new value").trigger("change"); > > That would trigger the "change" event when you update the value. > > >> $.fn.extend({ > >> val: function( val ) { > >> return val == undefined ? > >> ( this.length ? this[0].value : null ) : > >> this.attr( "value", val ).trigger("change"); > >> } > > >> }); > > -Dan