How to check the textfield is empty and then call javascript?
===

I  want to view the jqury/javascript dialog box when a perticular textbox is empty..I tried below code but doesnt work..how do I add if() function to below code?

   

       <script>
    
    $(document).ready(function(){
    
     $('#search_btn').click(function(){
    
    		if($('#form1.legacy_code_text.value')==""){ /// THIS DOESNT WORK I WANT THE CORRECT WAY FOR THIS LINE
    		$( "#dialog:ui-dialog" ).dialog( "destroy" );
    	
    		$( "#dialog-confirm" ).dialog({
    			resizable: false,
    			height:140,
    			modal: true,
    			buttons: {
    				"Ok": function() {
    					
    	   					$('#form1').submit();
       
    					
    					
    					//*****************************************************************
    				},
    				Cancel: function() {
    					$( this ).dialog( "close" );
    				}
    			}
    		
    		
    		});
    		}
    	});
    	});
    
    	</script>