Very nice work great. I really have to learn more jquery because it
works super.

On 3 feb, 21:06, Eric Garside <gars...@gmail.com> wrote:
> Change
> $('form').submit(function(){
> to
> $('input.counter').change(function(){
>
> This will prompt the check to run each time the user changes a value
> in any of the concerned fields.
>
> On Feb 3, 1:18 pm, "ebru...@gmail.com" <ebru...@gmail.com> wrote:
>
>
>
> > I get it now. I didn't add a submit button. Do you now if it's also
> > possible to use it without pressing on the submit so it would be a
> > realtime check.
>
> > On 3 feb, 19:08, Eric Garside <gars...@gmail.com> wrote:
>
> > > Ah, I'm pretty sure i missed wrapping the loop's "this" in a jQuery
> > > obj
>
> > > Try replacing this line:
> > > num += this.val()*1;
> > > with
> > > num += $(this).val()*1;
>
> > > Also, do an alert before and after the loop and just see what the
> > > values are:
> > > alert('Limit: ' + lim + "\nNum: " + num);
>
> > > On Feb 3, 12:58 pm, "ebru...@gmail.com" <ebru...@gmail.com> wrote:
>
> > > > Looking good Eric, i tied it out, but it doenst seem to work. I
> > > > already fixed the bug in the alert with the ' in it, but no reponse
> > > > when filling in alot of numbers.
>
> > > > On 3 feb, 17:48, Eric Garside <gars...@gmail.com> wrote:
>
> > > > > 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- Tekst uit oorspronkelijk bericht niet weergeven -
>
> > > > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit 
> > > > > oorspronkelijk bericht niet weergeven -
>
> > > - Tekst uit oorspronkelijk bericht weergeven -- Tekst uit oorspronkelijk 
> > > bericht niet weergeven -
>
> - Tekst uit oorspronkelijk bericht weergeven -

Reply via email to