if ( $('#edit-sPostalCode').val() != '' ) { stuff here }
$('#edit-sPostalCode').attr('val','') will actually create an input field attribute with the value '' and then return a jQuery object.
Saying !($('#edit-sPostalCode').attr('val','')) will then negate this jQuery object. Since the truthy object instance is in JS, the result of this expression will always be false .
source share