// I set the debug option to true, so the data is not commited, 
// enabling me to review the outcome.
$.validator.setDefaults({
	debug: false
});


$(document).ready(function() {
	 // validate signup form on keyup and submit
	$("#aanmelden").validate({
	
		//As soon as a key within a form field in “myform” is release then start
		event: "keyup",
		
		//Here the rules for the individual inputs are defined.
		rules: {
			
			//for id "username"
			organisatie: {
				required: true,
				minlength: 2
			},
			naam: {
				required: true,
				minlength: 2
			},
			functie: {
				required: true,
				minlength: 2
			},
			adres: {
				required: true,
				minlength: 3
			},
			postcode: {
				required: true,
				minlength: 2
			},
			plaats: {
				required: true,
				minlength: 2
			},
			email: {
				required: true,
				//It is an E-Mail address
				email: true
			},
			telefoon: {
				required: true,
				minlength: 10,
				digits: true
			},
			profiel: {
				accept: "doc"
			}
			/*,
			website: {
				required: true,
				url: true
			}*/
			
		},
		
		//Here the error messages for all rules are defined.
		messages: {
			organisatie: 'Vul de naam van uw organisatie in',
			naam: 'Vul uw naam in',
			functie: 'Vul uw functie in',
			geboortedatum: 'Vul uw geboortedatum in',
			adres: 'Vul uw adres in',
			telefoon: {
				required: 'Vul uw telefoonnummer in',
				minlength: 'Vul uw 10 cijferige telefoonummer in',
				digits: 'Alleen de cijfers van uw telefoonnummer'
			},
			postcode: 'Vul uw postcode in',
			plaats: 'Vul uw vestigingsplaats in',
			email: 'Vul een correct email adres in',
			website: 'Vul een correcte URL in, compleet met http://',
			attach: { required: 'Voeg uw CV toe' },
			profiel : {
				accept: 'Alleen Word (.doc) documenten toegestaan'
			}
		},
		
        // specifying a submitHandler prevents the default submit, good for the demo 
        //submitHandler: function() { 
        //    alert("submitted!"); 
        //}, 
        // set this class to error-labels to indicate valid fields 
        success: function(label) { 
            // set   as text for IE 
            label.html(" ").addClass("checked"); 
        }
	});
});
