Bug Tracker

Opened 13 years ago

Closed 12 years ago

#6221 closed bug (fixed)

Internet Explorer and NULL val()

Reported by: Vic D'Elfant Owned by:
Priority: low Milestone:
Component: manipulation Version: 1.4.2
Keywords: null val Cc:
Blocked by: Blocking:


Internet Explorer appears to be treating NULL as the string "null" when passed to an element's value property (or .val(), for that matter). If data is - for example - retrieved through AJAX and then passed to input fields to pre-fill a form, it is very impractical to check for NULL and run .val() on every call.

The attached patch improves the val() function by checking for NULL and setting this.value to an empty string if this is the case. The behaviour for non-null values remains untouched.

Attachments (1)

internet-explorer-null-vals.diff (331 bytes) - added by Vic D'Elfant 13 years ago.

Download all attachments as: .zip

Change History (5)

Changed 13 years ago by Vic D'Elfant


comment:1 Changed 12 years ago by kwikwag

I would say this is a bug, since this means val() is not cross-browser for null values. I vote for this one.

comment:2 Changed 12 years ago by SlexAxton

Keywords: null val added
Priority: low
Status: newopen
Type: enhancementbug

The patch is a nice help, so I'll push this through, but if you want to add a reduced test-case on a jsfiddle account, it may speed up the process of fixing this.

Switching to bug since it seems to be a crossbrowser inconsistency.

comment:3 Changed 12 years ago by Vic D'Elfant

Whilst posting the test case, I found out that this bug only affects 1.4.2 and appears to be fixed in 1.4.3:

http://www.jsfiddle.net/hNhtX - 1.4.3 http://www.jsfiddle.net/hNhtX/1 - 1.4.2

It works just fine in the latter.

comment:4 Changed 12 years ago by dmethvin

Resolution: fixed
Status: openclosed

Fixed in 1.4.3.

Note: See TracTickets for help on using tickets.