반응형
JavaScript Clear Textfield Default Value onClick
So basically if you have a text field with default text like “Enter Email Address Here” and you want it so that when the user clicks in it, the text disappears, this is the code to use. It goes one step further so that if you do not enter anything it puts the default text back and if there is something entered it doesn’t get tripped up and clear it out. Plus it is super simple and clean and tested in all browsers.
Here is the code:
function clearText(field){
if (field.defaultValue == field.value) field.value = '';
else if (field.value == '') field.value = field.defaultValue;
}
Here is how to use it:
<input name="emailaddress" type="text" value="Enter Your Email Address" onFocus="clearText(this)" onBlur="clearText(this)">
출처 http://www.bradino.com/javascript/clear-textfield-default-value-onclick/
출처 http://www.bradino.com/javascript/clear-textfield-default-value-onclick/
반응형
'Story > Javascript' 카테고리의 다른 글
사이트 북마크 - ie, ff, opera (0) | 2010.05.19 |
---|---|
네이버 지도 api 사용하기 (0) | 2010.01.13 |
FCKeditor_2.x 위지윅 에디터 (0) | 2009.10.07 |
javascript 로 특정 이미지위를 클릭했을때 이미지상 클릭한 좌표값 구하기 (0) | 2009.03.28 |
미디어 플레이어 플레이 목록 asx (0) | 2009.03.27 |