Disable diagonal movement in 3D

I wish to disable diagonal movement of my character in device, I am using something like the below mentioned code for movement.

var dir : Vector3 = Vector3.zero;
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;

if(Mathf.Abs(dir.x) > Mathf.Abs(dir.z)) {
dir.z = 0;
}
else {
dir.x = 0;
}

Just zero the smaller input.