js/jq form validation issue/help(jquery)
<p>So long story short, aside from being a noob, im not sure why this is not working.
overall i have different functions to check different things.</p>

<p>for the sake of this example, i have a form (one field to test) with a default value of say.. "enter name here". so the html below</p>

<pre><code>&lt;input type="text" value="enter name here" id="fieldOne"/&gt;
</code></pre>

<p>js below.</p>

<pre><code>// sample vars

var fieldOne = $('#fieldOne');
</code></pre>

<p><strong>//this function below will fire on blur.</strong></p>

<pre><code>function checkVal(){
    if($(this).val()== $(this).attr('defaultValue')){
        $(this).css("background-color","red");
        $(this).css("color","white");   
    } else if($(this).val()==""){
        $(this).css("background-color","red");
        $(this).css("color","white");   
        $(this).val("oopsiiee, you forgot this one");

    } else {
        $(this).css("background-color","green");
        $(this).css("color","white");   
    }

}
</code></pre>

<p>then on the form field, on blur i do this</p>

<p><code>fieldOne.blur(checkVal);</code> etc...</p>

<p>this above works,</p>

<p>Now since it has a default value, so i want it so that when user clicks on said field, that that def value disappears.</p>

<p>so i do something like this:</p>

<pre><code>function clearField(){
  $(this).val("");
}
</code></pre>

<p>this works</p>

<p><code>fieldOne.click(clearField);</code> etc...</p>

<p>problem now is that with this, even when the data has been changed from def to whatever, the mssg that was entered disppears again SOOooo, i want to edit this simple function so that, if the mssg is default, clear it. If the mssg is not default then that means its been changed so leave it.
so to this i write this which breaks the whole thing.</p>

<pre><code>function clearField(){
    if($(this).val() == $(this).attr('defaultValue')){
        $(this).val() == "";
    }
}
</code></pre>

<p>Not sure whats going on.</p>

<p>ive also tried</p>

<pre><code>function clearField(){
    if($(this).val() == $(this).attr('defaultValue')){
        $(this).attr('defaultValue') == "";
    }
}
</code></pre>

<p>Any tips, ideas, corrections etc i humbly accept/appreciate</p>

<p>Thanks in advanced.</p>
