Gauge invariance of string fields