Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select blank TextArea with value='' selector

Tags:

I have a text area that is required to be filled in before continuing on with a particular process.

For normal text boxes I can retrieve all the blank inputs by adding the attribute selector [value=''] the the selection string.

When I do that with text area it does not work.

If I am in IE and not in strict mode it does work, but that I not something that I want to do.

If I first select all text areas and then perform a filter call with [value=''] as the selector it does work.

Is this by design? It makes sense from the standpoint that a text area does not really have a value attribute, but I would guess that the filter call would not work.

Here is an example code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<HTML>
<HEAD>
    <SCRIPT SRC="jquery-1.4.2.min.js"></SCRIPT>

    <SCRIPT>
        $(function () {
            var Rslt1 = $("textarea[value='']").size(); 
            var Rslt2 = $("textarea").filter("[value='']").size();
            alert(Rslt1 + ' ' + Rslt2);
        })
    </SCRIPT>
</HEAD>
<BODY>
    <TEXTAREA></TEXTAREA>
</BODY>
</HTML>

In IE 8, Chrome 4 and Firefox 3.6 the result is 0 1 as described above.