A differential criterium for regularity of quaternionic functions