$(document).ready(function () {

    jQuery.validator.addMethod("lettersonly", function (value, element) {
        return this.optional(element) || /^[a-z]+$/i.test(value);
    }, "Please enter only letters");


    $("#uploadForm").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            courseTitle: {
                required: true,
               
            },
            courseDescription: {
                required: true,
               
    },
	
	userImage: {
                required: true,
               
    },
        },
        //set messages to appear inline
        messages: {
            courseTitle: {
                required: "This field is required",
               
    },
	courseDescription: {
                required: "This field is required",
               
    },
	userImage: {
                required: "This field is required",
               
    },
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $("#expenseValidation").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            datename: {
                required: true,
                
            },
			 expense_mode: {
                required: true,
                
            },
			 exAmount: {
                required: true,
                
            },
         
        },
        //set messages to appear inline
        messages: {
            datename: {
                required: " This field is required ",
               
    },
	 expense_mode: {
                required: " This field is required ",
               
    },
	 exAmount: {
                required: " This field is required ",
               
    },
            email: " ",
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $("#otherValidation").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            other_amount: {
                required: true,
                digits: true,
            },
			 other_remarks: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            other_amount: {
                required: " This field is required ",
               digits: "Digits only allowed",
    },
	 other_remarks: {
                required: " This field is required ",
               
    },
	
            email: " ",
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
    
    $("#createInvite").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            name: {
                required: true,                
            },
            email: {
                required: true,
                email: true
            },
            dateField: {
                required: true,                
            },
            mobile: {
                required: true,
                minlength: 10,
                maxlength: 10            
            },
        },
        //set messages to appear inline
        messages: {
            name: {
                required: " ",                
            },
            dateField: {
                required: " ",                
            },
            mobile: {
                required: " ",
                minlength: "",
                maxlength: ""
            },
            email: "",
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $(".ajax_permit_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            truck_permit_no: {
                required: true,                
            },
            truck_permit_date: {
                required: true,
                
            },
            truck_permit_from: {
                required: true,                
            },
            truck_permit_to: {
                required: true,
                        
            },
        },
        //set messages to appear inline
        messages: {
            truck_permit_no: {
                required: "This field is required ",                
            },
            truck_permit_date: {
                required: "This field is required ",                
            },
            truck_permit_from: {
                required: "This field is required ",
               
            },
            truck_permit_to: {
				required: "This field is required",
			}
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $(".ajax_rc_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            truck_rc_num: {
                required: true,                
            },
            truck_rc_date: {
                required: true,
                
            },
            truck_rc_to: {
                required: true,                
            },
           
        },
        //set messages to appear inline
        messages: {
            truck_rc_num: {
                required: "This field is required ",                
            },
            truck_rc_date: {
                required: "This field is required ",                
            },
            truck_rc_to: {
                required: "This field is required ",
               
            },
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $(".ajax_insurence_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            truck_insurence_num: {
                required: true,                
            },
            truck_insurence_from: {
                required: true,
                
            },
            truck_insurence_to: {
                required: true,                
            },
           
        },
        //set messages to appear inline
        messages: {
            truck_insurence_num: {
                required: "This field is required ",                
            },
            truck_insurence_from: {
                required: "This field is required ",                
            },
            truck_insurence_to: {
                required: "This field is required ",
               
            },
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $(".ajax_goods_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            goods_num: {
                required: true,                
            },
            goods_to: {
                required: true,
                
            },
            goods_from: {
                required: true,                
            },
           
        },
        //set messages to appear inline
        messages: {
            goods_num: {
                required: "This field is required ",                
            },
            goods_to: {
                required: "This field is required ",                
            },
            goods_from: {
                required: "This field is required ",
               
            },
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	 $(".ajax_others_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            truck_other_document: {
                required: true,                
            },
            truck_document_to: {
                required: true,
                
            },
          
        },
        //set messages to appear inline
        messages: {
            truck_other_document: {
                required: "This field is required ",                
            },
            truck_document_to: {
                required: "This field is required ",                
            },
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".ajax_road_upload").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            road_num: {
                required: true,                
            },
            road_on: {
                required: true,
                
            },
			 road_upto: {
                required: true,
                
            },
          
        },
        //set messages to appear inline
        messages: {
            road_num: {
                required: "This field is required ",                
            },
            road_on: {
                required: "This field is required ",                
            },
			 road_upto: {
                required: "This field is required ",                
            },
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".tripForm").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {    
            trip_type: {
                required: true,                
            },
            trip_route: {
                required: true,                
            },
            trip_departure: {
                required: true,
                
            },
			 trip_arrivel: {
                required: true,
                
            },
			 trip_driver: {
                required: true,
                
            },
			 trip_truck: {
                required: true,
                
            },
			 trip_starting: {
                required: true,
                
            },
			 
          
        },
        //set messages to appear inline
        messages: {
            trip_type: {
                required: "This field is required ",                
            },
            trip_route: {
                required: "This field is required ",                
            },
            trip_departure: {
                required: "This field is required ",                
            },
			 trip_arrivel: {
                required: "This field is required ",                
            },
			 trip_driver: {
                required: "This field is required ",                
            },
			 trip_truck: {
                required: "This field is required ",                
            },
			 trip_starting: {
                required: "This field is required ",                
            },
			 
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".truckForm").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            truck_brand: {
                required: true,                
            },
            truck_model: {
                required: true,
                
            },
			 truck_register_number: {
                required: true,
                
            },
			 truck_register_on: {
                required: true,
                
            },
			 truck_wheelers: {
                required: true,
                
            },
			 
          
        },
        //set messages to appear inline
        messages: {
            truck_brand: {
                required: "This field is required ",                
            },
            truck_model: {
                required: "This field is required ",                
            },
			 truck_register_number: {
                required: "This field is required ",                
            },
			 truck_register_on: {
                required: "This field is required ",                
            },
			 truck_wheelers: {
                required: "This field is required ",                
            },
			
			 
           
            },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$("#fuelValidation").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {            
            expense_fquantity: {
                required: true,                
            },
            expense_amount: {
                required: true,
                
            },
			 expense_fodometer: {
                required: true,
                
            },
			 expense_rate: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            expense_fquantity: {
                required: "This field is required ",                
            },
            expense_amount: {
                required: "This field is required ",
				digits:"Digits only allowed",                
            },
			 expense_fodometer: {
                required: "This field is required ",                
            },
			 expense_rate: {
                required: "This field is required ",                
            },
			  },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	 $("#searchReport").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            searchDate: {
                required: true,
                
            },
			 searchDateto: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            searchDate: {
                required: " This field is required ",
              
    },
	 searchDateto: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	 $("#searchRoute").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            searchDate: {
                required: true,
                
            },
			 searchDateto: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            searchDate: {
                required: " This field is required ",
              
    },
	 searchDateto: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	
	 $("#searchTrip").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            searchFrom: {
                required: true,
                
            },
			 searchTo: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            searchFrom: {
                required: " This field is required ",
              
    },
	 searchTo: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	
	
	 $("#idleValidation").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            idle_from: {
                required: true,
                
            },
			 idle_to: {
                required: true,
                
            },
			
			 idle_remarks: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            idle_from: {
                required: " This field is required ",
              
    },
	 idle_to: {
                required: " This field is required ",
               
    },  
	idle_remarks: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".tireAllocation").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            tirename: {
                required: true,
                
            },
			 truckname: {
                required: true,
                
            },
			
			 allocation_start: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            tirename: {
                required: " This field is required ",
              
    },
	 truckname: {
                required: " This field is required ",
               
    },  
	allocation_start: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".tireForm").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            tire_num: {
                required: true,
                
            },
			 tire_model: {
                required: true,
                
            },
			
			 tire_brand: {
                required: true,
                
            },
			
        },
        //set messages to appear inline
        messages: {
            tire_num: {
                required: " This field is required ",
              
    },
	 tire_model: {
                required: " This field is required ",
               
    },  
	tire_brand: {
                required: " This field is required ",
               
    },   
        },
        errorPlacement: function (error, element) {
            error.appendTo(element.parent());
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	$(".tireAllocationEdit").validate({
        errorElement: "span",
        errorClass: "inputError",
        successClass: "inputSuccess",
        //set the rules for the fild names
        rules: {
            allocation_end: {
                required: true,
                
            },
			
			allocation_allocated: {
                required: true,
                
            },
			
			
        },
        //set messages to appear inline
        messages: {
            allocation_end: {
                required: "This field is required",
              
    },
	
	allocation_allocated: {
                required: " ",
                
            },
	
        },
        errorPlacement: function (error, element) {
			
			if (element.attr("type") == "radio") {
                error.insertAfter(element.parent());
				$('.radioError').show();
            } else {
                error.appendTo(element.parent());
            }
           
        },
        highlight: function (element) {
            $(element).closest('.form-control').addClass('has-error');
        },
        success: function (element) {
			$('.radioError').hide();
            element.closest('.form-control').removeClass('has-error');
        }

    });
	
	

});