While people shouldn't ever put foam mattress pads in an automatic washing machine, and especially not the dryer, it is possible to wash them. Washing machines damage the structure because the high agitation of the washing cycles will shred the foam.
Instead, people should take the foam outside or into the bathtub and use a 2-1 ratio of detergent and water. They spray the solution over the pad and allow it to sink in. After about 45 minutes, they can rinse it with clean water and allow it to dry in indirect sun over the next few days, flipping it periodically to speed the process along.