The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] How to validate all the text area fields in a div

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • #149618

    How to validate all the text area fields in a div.

    <div id="Tile1"> <div class="fieldgroup"> <label>Label 1</label> <textarea rows ="4" cols="4"></textarea> </div> <div class="fieldgroup"> <label>Label 2</label> </div> <div class="fieldgroup"> <label>Label 3</label> <textarea rows ="4" cols="4"></textarea> </div> <div class="fieldgroup"> <label>Label 4</label> <textarea rows ="4" cols="4"></textarea> </div> </div>

    I want to call a function if all the textarea fields are not empty.

    How can i validate all the textarea fields using the div id.


    Wait….do you want to validate the contents (validation has a specific meaning in this context) or just check that the boxes have all been completed?

    You might also want to look into adding the required attribute.


    Hi paulie ,

    I just want to check if all textarea fields are having content (no matter with the length).
    I need validation code so that the textarea fields are not empty .

    On checkig that non empty textarea fields , i am calling another method.


    Yeah well that’s not precisely validation but i see what you mean.

    It might be better to refer to this as “all text areas must have been completed” rather than “textarea fields are not empty”/

    So, it sounds that you you need to validate each textarea in turn…so perhaps pattern checking (minimum length etc) within a bunch if if statements.

    Hmmm…Perhaps this?


    See…someone smart always turns up.

    Welcome back @jamygolden!


    I solved the issue by using this code.

    if($('#Tile').find(textarea[value!=""]).length == 4)
    which evaluates only if all textarea fields are filled.

    Thanks jamygolden and paulie for the replies.

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.