Cases of the winter vomiting bug norovirus have been confirmed on wards at Pinderfields and Dewsbury hospitals.
Bosses at Mid Yorkshire Hospitals Trust are urging people with symptoms of norovirus not to visit family and friends in hospital to avoid spreading the illness.
Consultant microbiologist Dr Lucia Paraja-Cebrian said anyone with nausea, vomiting, diarrhoea, headaches and abdominal pains should not visit hospitals until they were free of the symptoms for at least 48 hours.
Dr Paraja-Cebrian said: “One of the most effective ways of stopping the spread is for people with symptoms of norovirus to stay away from visiting friends and family in our hospital.
“This is especially important as as some patients may have underlying health conditions and already vulnerable.
“It’s also important that when visiting our hospitals, either as a patient or visitor, that you regularly wash your hands using soap and water and follow any infection prevention advice you are given by staff.
“If you need advice it is best to phone NHS 111 or your doctor.”