Great advice and assistance got me looking in the right direction. Thank you. Got this code working:
$(document).ready(function(){ $("# test").blur(function () { $('#test').val($('#test').val().replace(/,/g,'')); }); }); On Sep 29, 9:58 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > Works for me. > > Bear in mind you're selecting every input on the page by virtue of > $('input'). > > Bear in mind further that on blur for every input, you're telling jquery to > remove the commas from the element with id="test" (by virtue of $('#test'). > > Do you have an element with id="test" ? > > On Tue, Sep 29, 2009 at 1:53 PM, factoringcompare.com < > > > > > > firstfacto...@googlemail.com> wrote: > > > No it doesn’t work. I’ll work it out. > > > <script> > > $(document).ready(function(){ > > > $("input").blur(function () { > > $('#test').val($('#test').val().replace(/,/g,'')); > > }); > > > }); > > </script> > > > On Sep 29, 9:42 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > > > Because it's completely new to you is exactly why you should be reading > > the > > > docs :) > > > > Does the code below run? > > > > On Tue, Sep 29, 2009 at 1:27 PM, factoringcompare.com < > > > > firstfacto...@googlemail.com> wrote: > > > > > Thank you. JQuery is completly new to me. OK how des the belo code > > > > look? > > > > > <script> > > > > $(document).ready(function(){ > > > > > $("#test'").blur(function () { > > > > $('#test').val($('#test').val().replace(/,/g,'')); > > > > }); > > > > > }); > > > > </script> > > > > > On Sep 29, 9:17 pm, Charlie Griefer <charlie.grie...@gmail.com> wrote: > > > > > jQuery is based on "find something -> do something". The "find > > > > something" > > > > > is largely done with selectors (similar to CSS selectors). > > > > > > you want to find the element with the id="test". that would be > > > > $('#test') > > > > > > you want it to do something when that element receives a blur > > event... > > > > > > $('#test').blur(); <-- that's the event, but it's not doing anything > > yet. > > > > > To do something, pass a function to the blur(): > > > > > > $('#test').blur(function() { }); > > > > > > which, when fleshed out a little more, might look like: > > > > > > $('#test').blur(function() { > > > > > alert('I just got blurred!'); > > > > > > }); > > > > > > While inside these "inner functions", you have a handle on the > > element > > > > that > > > > > triggered it. It's referred to as $(this). You can also use "plain > > ol' > > > > > javascript" and use 'this' (no quotes). Depends on what you're doing > > > > with > > > > > it. > > > > > > $('#test').blur(function() { > > > > > alert(this.id); > > > > > alert($(this).attr('id')); // they do the same thing > > > > > > }); > > > > > > Most of this (if not all of it) is covered in the docs. > > > > > >http://docs.jquery.com/andhttp://docs.jquery.com/How_jQuery_Works > > > > > > On Tue, Sep 29, 2009 at 1:04 PM, factoringcompare.com < > > > > > > firstfacto...@googlemail.com> wrote: > > > > > > > Thank you. Could you elaborate on the code so that I can track it > > > > > > through and understand > > > > > > > On Sep 29, 8:49 pm, Charlie Griefer <charlie.grie...@gmail.com> > > wrote: > > > > > > > $('#test').blur(function() { > > > > > > > $(this).val($(this).val().replace(/,/g,'')); > > > > > > > > }); > > > > > > > > You "call" it by telling jQuery to "listen" for the blur() event > > on > > > > the > > > > > > > element with id="test" (line 1 above). > > > > > > > > Your code was correct, but you can replace the $('input#test') > > with > > > > > > $(this), > > > > > > > since $(this) will be a reference to the element that triggered > > the > > > > blur. > > > > > > > > On Tue, Sep 29, 2009 at 12:04 PM, factoringcompare.com < > > > > > > > > firstfacto...@googlemail.com> wrote: > > > > > > > > > Hi, > > > > > > > > > New to jQuery. > > > > > > > > > I would like to strip out all of the commas in numeric text > > field > > > > > > > > called test on blur. New to jQuery. I have had a go at coding > > would > > > > it > > > > > > > > work? > > > > > > > > > $('input#test').val($('input#test').val().replace(/,/g,'')); > > > > > > > > > and ....... how do i calll it? > > > > > > > > -- > > > > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > > > I have failed as much as I have succeeded. But I love my life. I > > love > > > > my > > > > > > > wife. And I wish you my kind of success. > > > > > > -- > > > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > > > I have failed as much as I have succeeded. But I love my life. I love > > my > > > > > wife. And I wish you my kind of success.- Hide quoted text - > > > > > > - Show quoted text - > > > > -- > > > Charlie Grieferhttp://charlie.griefer.com/ > > > > I have failed as much as I have succeeded. But I love my life. I love my > > > wife. And I wish you my kind of success.- Hide quoted text - > > > > - Show quoted text - > > -- > Charlie Grieferhttp://charlie.griefer.com/ > > I have failed as much as I have succeeded. But I love my life. I love my > wife. And I wish you my kind of success.- Hide quoted text - > > - Show quoted text -