form textarea require 5 of 10 to be filled out

HTML, CSS and anything else that deals with client side capabilities.

Moderator: General Moderators

Post Reply
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

form textarea require 5 of 10 to be filled out

Post by Eric! »

Has anyone seen some solutions to a problem where you have many textareas on a form but you only require a few of them to be filled out?

I could wait for it to be submitted then repost the form with markup, but it would be nice to do something more interactive. Maybe a javascript count down of (3/5 filled out so far...)? I'm just looking for some ideas/examples so I don't have to reinvent a solution.

Thanks!
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: form textarea require 5 of 10 to be filled out

Post by Christopher »

Whatever the logic is, it would be done in Javascript. If you give some specifics on what the rules are for the form, maybe people could give you specific ideas/examples.
(#10850)
Eric!
DevNet Resident
Posts: 1146
Joined: Sun Jun 14, 2009 3:13 pm

Re: form textarea require 5 of 10 to be filled out

Post by Eric! »

The rules are pretty simple. You have a list of input textareas that you could group by class selector. The form would need to know if you have filled out at least 5 of them.

I did something like this:

Code: Select all

(function($) {
    $('#form_register').on('keyup change', function() {
        var number = 0;
        $(this).find('textarea[class=group1]').each(function(){
           if( $(this).val().length > 2){
               number++;
               $(".input_count").html(number+" of Required 5 Completed.");       
           }
        });       
    }); 
})(jQuery);
Which just counts how many of the textareas with the group1 class have characters over 2 in them. But I don't really like the look and feel of it. So I was looking for some other ideas. Perhaps ajax verification would have a nicer way feed back to the user? I'm just looking for some ideas.
Post Reply