tags:

views:

27

answers:

4

Hi Guys.

Is there any jquery event which is called when the readonly value of the text box is changed automatically

I want to call an event (jquery) which should be called when the readonly value of the textbox is changed some how by other jquery events.

Early Reply is highly appreciated.

Best Regards, Sagar

+1  A: 

There is no event for this (not one you would want to attach to, a general DOM change event handler would have horrible performance).

If you expanded on the context a bit, there may be another solution to get what you're after, for example what's setting it to readonly?

Nick Craver
A: 

would the change() method not work?

$('input:readonly').change(function() {
   alert("Readonly input changed!!");
})
Zane Edward Dockery
The `change` method isn't related to other attributes at all...
Nick Craver
A: 

You could add a function that will be executed every N seconds (via setInterval) and check for the field value. It is very ugly, though.

floatless
+1  A: 

You could add a change event to your <input> and test for the readonly attribute:

$('input').change(function(){
    if($(this).attr('readonly') == true){
        // do something fancy
    } 
});
Pat
This doesn't answer the question...this checks for an attribute when a `change` event from something *else* happens. Since it's `readonly` that event won't fire, since the person won't be focusing/bluring the element. Also, this checks for the *presence* not the *change* of the `readonly` attribute.
Nick Craver
I realized that a few minutes after posting - apparently the coffee hasn't kicked in yet...
Pat