Is it possible to use a raycast to limit jumping?

I was wondering if anyone can think of a way to limit the ability of jumping to only when a raycast returns specific ranges of values. This is what I have so far for my character controller script. The jumping bit is at the bottom.

` #pragma strict

//Player Movement
private var moveHorizontal : float;
private var moveVertical : float;
private var movement : Vector3;
private var sprint : int;
public var speed : float;
public var jumpForce : float;

function Update () {

	//default sprint multiplier
	sprint = 1;
	
	if (Input.GetKey(KeyCode.LeftShift)) {
		
		//"while sprinting" multiplier
		sprint = 2;
		
	}
}

function FixedUpdate() {
	
	//defines movement input
	moveHorizontal = Input.GetAxis("Horizontal");
	moveVertical = Input.GetAxis("Vertical");
	
	//sets force amount for movement variable
	movement = Vector3(moveHorizontal,0,moveVertical);

	//applies force to player object
	rigidbody.AddForce(movement*sprint*speed*Time.deltaTime);

	//limits jumping
	if (Input.GetKeyDown(KeyCode.Space) && transform.position.y < .49 && transform.position.y > .47){
		rigidbody.AddForce(Vector3.up*jumpForce);
	}
	if (Input.GetKeyDown(KeyCode.Space) && transform.position.y > .49){
	}
	if (Input.GetKeyDown(KeyCode.Space) && transform.position.y < .47){

	}
}`

I figured it out here is the code

public var jumpForce : float;
public var hit : RaycastHit;
public var distanceToGround;

function Update () {

	if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
		distanceToGround = hit.distance;
		
	}
}
	
function FixedUpdate() {
	
	//limits jumping
	if (Input.GetKeyDown(KeyCode.Space) && (hit.distance <= .5)){
		rigidbody.AddForce(Vector3.up*jumpForce);
		
	}
}