Bug Tracker

Ticket #2416 (closed bug: fixed)

Opened 9 months ago

Last modified 7 months ago

setting a form field's value to empty string fails

Reported by: luka.kladaric Assigned to: anonymous
Type: bug Priority: major
Milestone: 1.2.4 Component: core
Version: 1.2.3 Keywords:
Cc: Needs: Review

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

Attachments

Change History

Changed 7 months ago by flesler

  • status changed from new to closed
  • resolution set to fixed

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

Reopen if still failing.

Note: See TracTickets for help on using tickets.