Ticket #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: | |
| Blocking: | Blocked by: |
Description
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
Change History
Changed 3 years ago by Vic D'Elfant
-
attachment
internet-explorer-null-vals.diff
added
comment:1 Changed 3 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 3 years ago by SlexAxton
- Keywords null val added
- Priority set to low
- Type changed from enhancement to bug
- Status changed from new to open
- Milestone changed from 1.4.3 to 1.5
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 3 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.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Patch