SoFunction
Updated on 2025-03-02

Sample code for JS text to get focus clear text words


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:///TR/xhtml1/DTD/">
<html xmlns="http:///1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Unt titled document</title>
<style type="text/css">
.clearFieldBlurred{
    color:#ccc;
    font-style:italic;
    font-weight:normal;
    width:150px;
}

.clearFieldActive{
    color:#4e4e4e;
    font-weight:bold;
    width:150px;
}
</style>
<script type="text/javascript">
function clearFiled(){
    var bbb=("bbb");
    if(=="bbb"){
        ='';
        ='clearFieldActive';
    }
}

=function(){
    var bbb=('bbb');
    if(==""){
    ='bbb';
    ='clearFieldBlurred';
    }
}
</script>
</head>

<body>
<input type="text"   value="aaa" class="clearFieldBlurred" onfocus="if(=='aaa'){='';='clearFieldActive';}"  onblur="if(==''){='aaa';='clearFieldBlurred';}"/>
<br />
<input type="text" value="bbb" class="clearFieldBlurred" onclick="clearFiled()"  />
</body>
</html>