
/*
Function force_numeric($value)
 Accepts a string and returns only numeric parts of that string, only returns first decimal point found. 

Typical usage:

<script language="javascript" src="/javascript/force_date.js" type="text/javascript"></script>

<form name="form1">
 <input type="text" name="test" id = "test1" onChange="this.value = force_date(this.value);"> 
</form>


*/

function check_date($val) {
  if ($val.length > 0) {
	  x = new Date($val)
	  if (isNaN(x.getUTCMonth()))
	   {
	   alert("I did not understand the date you entered")
	   return ""
	   }
	  if (x.getUTCFullYear() < 1990)
		if (x.getUTCFullYear() > 1900)
		   x.setFullYear(x.getUTCFullYear()+100)
		   
	  str_month = "00" + (x.getUTCMonth()+1)
	  str_month = str_month.substring(str_month.length -2)
	  str_day = "00"  + x.getUTCDate()
	  str_day = str_day.substring(str_day.length -2)
	  str_year = "" + x.getUTCFullYear()
	
	  $output = str_month+"/"+str_day+"/"+str_year
	
	 return $output
 }

 }

function force_date($ref) {
  if ($ref.value.length > 0) {
	  x = new Date($ref.value)
	  if (isNaN(x.getUTCMonth()))
	   {
	   alert("I did not understand the date you entered")
	   // push focus back onto the textbox
	   $ref.focus()
	   return false
	   }
	  if (x.getUTCFullYear() < 1990)
		if (x.getUTCFullYear() > 1900)
		   x.setFullYear(x.getUTCFullYear()+100)
		   
	  str_month = "00" + (x.getUTCMonth()+1)
	  str_month = str_month.substring(str_month.length -2)
	  str_day = "00"  + x.getUTCDate()
	  str_day = str_day.substring(str_day.length -2)
	  str_year = "" + x.getUTCFullYear()
	
	  $output = str_month+"/"+str_day+"/"+str_year
	  $ref.value = $output

	// return $output
 }

 }
