开发者

disable enable a textfield dynamically

Hi I was trying to make a textfield dynamic. This is my code

 <input type="text" id="test1" value ="dynamic" onfocus="this.disabled=true" onblur="this.disabled=false">
    <input type="text" id="test2">

so fields get disabled per开发者_Python百科fectly but doesnt get enabled on blur. If any one here can solve my problem that would be great.


Perhaps in this situation it is better to make the field readonly and add some custom class to make it look like it is disabled.

Since disabled element are well... disabled :)

EDIT

I've done some testing and it gets enabled again on blur!

http://jsfiddle.net/dfhHz/

You still need to click outside the input to trigger the blur ofcourse

EDIT2

WHat would you like to achieve. Since this functionality looks a bit strange (disable on focus and enable on blur) to me :)


Why don't you use onmouseover and onmouseout events on your text field instead ?

<input type="text" id="test1" value="dynamic" onmouseover="this.disabled=true" onmouseout="this.disabled=false">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜