[jQuery] Re: setting focus to the first empty field
What about when using jquery tabs? I have a form that's very long. Each tab shows another section of the form. It would be nice to focus on the first empty field every time you click a tab and load it's content. On Feb 4, 7:53 pm, Ricardo Tomasi wrote: > $('[value=""]') seems to be broken in 1.3.1 (fixed in the nightlies, > seehttp://dev.jquery.com/ticket/3990), so that would be > > $('form input[value=]:first').focus(); > > cheers, > - ricardo > > On Feb 4, 7:38 pm, Klaus Hartl wrote: > > > $('form input[value=""]:first').focus(); > > > --Klaus > > > On 4 Feb., 20:57, Massiverse wrote: > > > > Hello > > > > I'm a newbie, here's what I need to do (searched the forums first but > > > couldn't find the answer). > > > > 1. Search form for an empty input field. > > > 2. If an empty field exists, set the focus on the field. > > > 3. If no empty fields exist, do nothing. > > > > Thanks, > > > > August
[jQuery] Re: setting focus to the first empty field
$('[value=""]') seems to be broken in 1.3.1 (fixed in the nightlies, see http://dev.jquery.com/ticket/3990), so that would be $('form input[value=]:first').focus(); cheers, - ricardo On Feb 4, 7:38 pm, Klaus Hartl wrote: > $('form input[value=""]:first').focus(); > > --Klaus > > On 4 Feb., 20:57, Massiverse wrote: > > > Hello > > > I'm a newbie, here's what I need to do (searched the forums first but > > couldn't find the answer). > > > 1. Search form for an empty input field. > > 2. If an empty field exists, set the focus on the field. > > 3. If no empty fields exist, do nothing. > > > Thanks, > > > August
[jQuery] Re: setting focus to the first empty field
$('form input[value=""]:first').focus(); --Klaus On 4 Feb., 20:57, Massiverse wrote: > Hello > > I'm a newbie, here's what I need to do (searched the forums first but > couldn't find the answer). > > 1. Search form for an empty input field. > 2. If an empty field exists, set the focus on the field. > 3. If no empty fields exist, do nothing. > > Thanks, > > August
[jQuery] Re: setting focus to the first empty field
$("#FormID input").each(function() { if ($.trim($(this).val()) == "") { $(this).focus(); return false; //exits loop } }); On Feb 4, 2:57 pm, Massiverse wrote: > Hello > > I'm a newbie, here's what I need to do (searched the forums first but > couldn't find the answer). > > 1. Search form for an empty input field. > 2. If an empty field exists, set the focus on the field. > 3. If no empty fields exist, do nothing. > > Thanks, > > August
[jQuery] Re: setting focus to the first empty field
Something like this, perhaps? $(input :not([value])).focus() On Wed, Feb 4, 2009 at 11:57 AM, Massiverse wrote: > > Hello > > I'm a newbie, here's what I need to do (searched the forums first but > couldn't find the answer). > > 1. Search form for an empty input field. > 2. If an empty field exists, set the focus on the field. > 3. If no empty fields exist, do nothing. > > Thanks, > > August >