//validateField(Form name, Textfield Name, ['number' or 'email' or 'null'] ) 
      
function validateField(formName, textField, restrict){ 

          var tBox        	= eval("document."+formName+"." + textField); 
          var textValue 	= LTrim(tBox.value); 
          switch (restrict){ 
               case 'number': 
                    if(!isNaN(tBox.value)){ 
                         return true; 
                    }else{ 
                         tBox.focus(); 
                         return false; 
                    } 
                    break; 
               
			   	case 'page_num':
			   		if(!isNaN(tBox.value) && tBox.value != "" && tBox.value > 0 ){ 
						
                         return true; 
                    }else{ 
						
                         tBox.focus(); 
                         return false; 
                    } 
                    break; 
					
               case 'email': 
						  var rule 	= /^[\w\-]+(\.[\w\-]+)*@([\w\-]+\.)+([a-z]{2,4})$/i;
						  if(!rule.test(tBox.value)){
							  	tBox.focus(); 
							   return false;
						  }
						  return true;
						  break; 
               
               case 'null': 
                    if(LTrim(tBox.value) == "" || tBox.value =="XX" || tBox.value ==" "){ 
                         tBox.focus(); 
                         return false; 
                    }else{ 
                         return true; 
                    } 
                    break; 
					
					case 'not_null': 
                    if(tBox.value != "" ){ 
                         return false; 
                    }else{ 
                         return true; 
                    } 
                    break; 
										
               case 'url': 
					 	var re = new RegExp("\\b(http)|(https)|(ftp)://www.\\w*","i");
                  if(!tBox.value.match(re)){ 
                         tBox.focus(); 
                         return false; 
                    }else{ 
                         return true; 
                    } 
                    break; 		
				
			   	default:						
						alert('Please specify key to validate');
						break; 
					
          } 
}

function LTrim(sString) 
{ 
     while (sString.substring(0,1) == ' ') 
     { 
          sString = sString.substring(1, sString.length); 
     } 
     return sString; 
}

/*
 if(!validateField(formName, 'veh_model','null')){ 
          alert("Please specify the Model"); 
          return false; 
     }
	 
*/	
