Sorry for that last post, wrong thread. :(

Anyway, you could try something like this:

<form>
<input id="lim" type="hidden" value="40"/>
<input id="input_1" type="text" class="counter"/>
<input id="input_2" type="text" class="counter"/>
<input id="input_3" type="text" class="counter"/>
<input id="input_4" type="text" class="counter"/>
<input id="input_5" type="text" class="counter"/>
<input id="input_6" type="text" class="counter"/>
</form>

$(function(){
    $('form').submit(function(){
        var num = 0, lim = $('#lim').val()*1;
        $('input.counter').each(function(){
            num += this.val()*1;
        });
        if (num > lim){
            alert('You can't take more than ' + lim + ' bags, but you
have selected ' + num + ' bags!');
            return false;
        }
    });
});

On Feb 3, 11:33 am, Stephan Veigl <stephan.ve...@gmail.com> wrote:
> Hi Erwin,
>
> Of course you can code it by hand, but I would suggest that you take a
> look at the various validation plugins for jQuery 
> (e.g.http://plugins.jquery.com/project/validate) first.
>
> by(e)
> Stephan
>
> 2009/2/3 ebru...@gmail.com <ebru...@gmail.com>:
>
>
>
> > Hello,
>
> > I have a site where i want to run a realtime check.
>
> > I have 6 form fields, when someone fills a number in jquery has to
> > check if he doesn't go over the max what he can fill in.
>
> > So for example he kan take 40 bags:
> > Field one he fills in 10
> > Field two he fills in 10
> > Field three he fills in 10
> > Field four he fills in 10
> > Field five he fills in 10
> > Field six he fills in 10
>
> > He wants to take 60 bags thats over the max he can take so there has
> > to show a messages on the website:
> > You can't take more then 40 bags you have selected 60 bags now!
>
> > If he takes 40 bags the only thing there has to showup is how much he
> > has filled in total.
>
> > Any one how can advise me on how to fix this.
>
> > Erwin

Reply via email to