Skip to main content

Bug Tracker

Side navigation

#2416 closed bug (fixed)

Opened February 26, 2008 05:13PM UTC

Closed May 21, 2008 05:50PM UTC

setting a form field's value to empty string fails

Reported by: luka.kladaric Owned by:
Priority: major Milestone: 1.2.4
Component: core Version: 1.2.3
Keywords: Cc:
Blocked by: Blocking:

i'm trying to make a selective form field reset to initial values

this is achieved by copying all initial values into a new attribute

$('.billing input:text').each(function () { $(this).attr('original_value', $(this).attr('value')); });

and then restoring it as necessary with

$(this).attr('value', $(this).attr('original_value'));

this consistently fails in FF2/Win for form fields which had an empty string as their initial value and works for other fields

so to reproduce:

have two fields, one with value="foo", other with value=""

set both field contents to "bar", manually

run mentioned code

expected behaviour:

field1 reverts to "foo", field2 reverts to ""

found behaviour:

field1 reverts to "foo", field2 stays as "bar"

firebug shows both fields as reverted, but firefox does not update the displayed value for field2


instead of .attr('value', '') use .removeAttr('value')

using .val() instead of .attr('value') makes no difference

Attachments (0)
Change History (1)

Changed May 21, 2008 05:50PM UTC by flesler comment:1

resolution: → fixed
status: newclosed

This should be fixed after the modification to .attr().

Reopen if still failing.