The effect of cosmic rays on the Parker-Jeans instability in magnetized self-gravitating gaseous disks is studied using three-dimensional magnetohydrodynamic simulations with cosmic rays taken as a massless fluid with notable pressure. Cosmic-ray diffusion along the magnetic field is taken into account in the simulation. The initial configuration of the disk is a magnetized cold gas slab sandwiched between hot coronae (on top and bottom). We show that cosmic rays play an important role in the formation of filaments or clumps in some parameter regimes. In a certain range of the thickness of the gas slab, the cosmic-ray diffusion coefficient plays a decisive role in determining whether the filaments lie along or perpendicular to the magnetic field. We also consider the effect of rotation on the system.