Hey all, I'm using a handy function written by Thomas Fuchs for using an input field as a hint. The problem is, I want to use a password field as a hint also. I tried doing things like $('password').type = 'text', things like that to change the type on the fly, but IE doesn't support this. I then tried cloning the node and replacing it, but this loses the binding of the element to the function (it is no longer "observed" by focus or blur). Does anyone have an idea or experience doing this? Here is the code as I have it, but it's getting a bit convoluted and doesn't work 100%. Thanks...
(function() { var methods = { defaultValueActsAsHint: function( element ) { element = $(element); element._default = element.value; //element._type = element.type; if( element.type == 'password' ) { var e = element.cloneNode(true); e.type = 'text'; Element.replace(element,e); e.defaultValueAsHint(); e._type = 'password'; } return element.observe('focus', function() { if(element._default != element.value) return; console.log(element.type); if( element._type == 'password' ) { var e = element.cloneNode(true); e.type = 'password'; Element.replace(element,e); element = e; e._type = 'text'; e.focus(); e.defaultValueAsHint() } element.removeClassName('hint').clear(); }).observe('blur', function() { console.log(element.type); if(element.value.strip() != '') return; if( element.type == 'password' ) { var e = element.cloneNode(true); e.type = 'text'; Element.replace(element,e); e.defaultValueAsHint(); e._type = 'password'; } element.addClassName('hint').value = element._default; }).addClassName('hint'); } }; $w('input textarea').each(function(tag){ Element.addMethods(tag, methods) }); })(); --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~----------~----~----~----~------~----~------~--~---