// To check if all the fields in the form are correctly filled.
// Validation - Reports if all the fields are filled out correctly

function checksearchreqmt()
{
 if (testformsearchreqmt()) return true;
 else return false;	
}		

function testformsearchreqmt()
{

 var model = document.searchreqmt.model.selectedIndex;
 if (document.searchreqmt.model.options[model].value == '')
 {
  alert('Please select your car make');       				
  document.searchreqmt.model.focus();
  return false;
 }

 var place = document.searchreqmt.place.selectedIndex;
 if (document.searchreqmt.place.options[place].value == '')
 {
  alert('Please select your city/town');       				
  document.searchreqmt.place.focus();
  return false;
 }

 var vyear = document.searchreqmt.vyear.selectedIndex;
 if (document.searchreqmt.vyear.options[vyear].value == '')
 {
  alert('Please select the year of manufacture');       				
  document.searchreqmt.vyear.focus();
  return false;
 }

 var price = document.searchreqmt.price.value;
 if (price == "")
 {
  alert("Please enter your minimum expected price");       				
  document.searchreqmt.price.focus();
  return false;
 }

 // Return false if characters are not 0-9
 for (var i = 0; i < price.length; i++)
 {
  var ch = price.substring(i,i+1);
  if ((ch < "0") || ("9" < ch))
  {         
   alert("The price field has to be a whole number.\n\nPlease re-enter your minimum expected price correctly and without commas.");         			
   document.searchreqmt.price.focus();         
   document.searchreqmt.price.select();         
   return false;         
  }      
 }

 return true;
}

