The value of the field cannot be null; it is always a string value.
The code checks to see if the string value is a "NULL" string. You want to check if this is an empty string:
if ($('#person_data[document_type]').val() != ''){}
or
if ($('#person_data[document_type]').val().length != 0){}
If you want to check if an element exists at all, you must do this before calling val :
var $d = $('#person_data[document_type]'); if ($d.length != 0) { if ($d.val().length != 0 ) {...} }
Guffa Nov 22 '10 at 10:47 2010-11-22 10:47
source share