Limit rotation (Horizontal and vertical input)

Hello, So I need to limit the rotation on an object that is controlled by keyboard to rotate on both the Z and X axis. I would like to be able to limit how much the object rotates to 20 degrees either direction from the 0 point of rotation. So this would mean the object could rotate -20 degrees and +20 degrees on both x and z.

I have been trying like crazy to use the Mathf.Clamp, however I have yet to get it to work… things just start popping all over the place… I could really use a hand on a best method for doing this. Thank you so much in advance.

Here is my code:

function Start () {

}
var rotateObject: GameObject;

function Update () {

if (Input.GetAxis("Horizontal") > 0) {
rotateObject.transform.localEulerAngles.z -= 10 * Time.deltaTime; //right
}

if (Input.GetAxis("Horizontal") < 0) {
rotateObject.transform.localEulerAngles.z += 10 * Time.deltaTime; //left
}

if (Input.GetAxis("Vertical") > 0) {
rotateObject.transform.localEulerAngles.x += 10 * Time.deltaTime; //forward
}

if (Input.GetAxis("Vertical") < 0) {
rotateObject.transform.localEulerAngles.x -= 10 * Time.deltaTime; //backward
}

}

Do like this:

var tmp = rotateObject.transform.localEulerAngles.z - 10 * Time.deltaTime;
rotateObject.transform.localEulerAngles.z = Mathf.Clamp(tmp, -20, 20);

EDIT:

var tmp = rotateObject.transform.localEulerAngles.z - 10 * Time.deltaTime;
if (tmp < 20 || tmp > 340) {
  rotateObject.transform.localEulerAngles.z = tmp;
}