Random movement of crosshair inside ui box

I want to make a crosshair move randomly inside a ui box. At every move it should generate a Random vector only inside the bounding box and then the crosshair should move to that position

Use this: (replace the 5’s with your box’s dimensions.)

float newX = Random.Range(-5,5);
float newY = Random.Range(-5,5);
transform.position = new Vector2(newX,newY);