<script type="text/javascript" charset="utf-8">
/* -------------------------------------------------------------------------------
As it turns out, this way isn't as efficient as initially thought. Yes, the code
is small and light (not as light as jQuery, but that's another topic entirely. As
I understand it, the 'click' and 'blur' will always fire regardless of where you
click on the page. If you are concerned about how many times users click on your
page, I suggest looking at Part II:
http://snipt.net/ritcheyer/clear-input-using-prototype-part-ii
------------------------------------------------------------------------------ */
document.observe('click',function(event) {
var e = event.element();
var defaultValue = e.value;
if(e.match('input[class="input"]')) {
// -- clear input field
e.clear();
}
// -- if input looses focus replace value
e.observe('blur', function() {
if(e.value == '' || e.value == defaultValue) {
e.value = defaultValue;
}
});
});
</script>
js
1
<scripttype="text/javascript"charset="utf-8">/* ------------------------------------------------------------------------------- As it turns out, this way isn't as efficient as initially thought. Yes, the code is small and light (not as light as jQuery, but that's another topic entirely. As I understand it, the 'click' and 'blur' will always fire regardless of where you click on the page. If you are concerned about how many times users click on your page, I suggest looking at Part II: http://snipt.net/ritcheyer/clear-input-using-prototype-part-ii ------------------------------------------------------------------------------ */document.observe('click',function(event){vare=event.element();vardefaultValue=e.value;if(e.match('input[class="input"]')){// -- clear input fielde.clear();}// -- if input looses focus replace valuee.observe('blur',function(){if(e.value==''||e.value==defaultValue){e.value=defaultValue;}});});</script>
Hey there! I see you're running Internet Explorer 6.
That's neat. This reminds me of my grandpa. He had this old car that he kept having to fix. He spent so much money on it that he didn't want to get rid of it (even when it stopped running).
0 Comments