﻿
function js_validate()
{
    var DropDownList1 = document.getElementById(GetClientId("DropDownList1"));
    var TextBoxMinutes = document.getElementById(GetClientId("TextBoxMinutes"));
    var TextBoxWeight = document.getElementById(GetClientId("TextBoxWeight"));
    
    var val;
    
    //validate DropDown selection
    val = DropDownList1.selectedIndex;
    if (val == 0)
    {
        alert('Please select an activity from the dropdown.');
        return false;
    }
    
     //validate Minutes
    val = TextBoxMinutes.value;
    if (IsNumeric(val) == false)
    {
        alert('Minutes must be a number.');
        return false;
    }
    
    //validate weight
    val = TextBoxWeight.value;
    if (IsNumeric(val) == false)
    {
        alert('Weight must be a number.');
        return false;
    }
}


function IsNumeric(strString)
   //check for valid numeric strings	
   {
   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

