Bug Tracker

Opened 12 years ago

Closed 12 years ago

#2416 closed bug (fixed)

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:

Description

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

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

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

Change History (1)

comment:1 Changed 12 years ago by flesler

Resolution: fixed
Status: newclosed

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

Reopen if still failing.

Note: See TracTickets for help on using tickets.