Ajax wordpress function showing source code in alert and not value of input field?

Move the AJAX handler function hook outside of init callback and hook your script registrations to wp_enqueue_scripts. And, the hook to attach the handler callback would be wp_ajax_nopriv_postcode_ajax2.

function ajax_postcode_form_init() {
    wp_register_script('ajax-login-script', get_bloginfo('stylesheet_directory'). '/ajax-postcode-script.js', array('jquery') ); 

    wp_localize_script( 'ajax-login-script', 'ajax_login_object', array( 
        'ajax_url' => admin_url( 'admin-ajax.php' ),
    ));

    wp_enqueue_script('ajax-login-script');

}

add_action('wp_enqueue_scripts', 'ajax_postcode_form_init');

function postcode_ajax2()  {
$postcode = false;
if(isset($_POST['postcode'])){
    $postcode = $_POST['postcode'];
}

echo 'Received postcode was: ' . $postcode;

die();

}
add_action( 'wp_ajax_nopriv_postcode_ajax2', 'postcode_ajax2' );