$(function(){ new FormValidator('register-form', [{name: 'email',display: 'Email',rules: 'trim|required|valid_email|is_unique[tbl_customers.cus_email]|max_length[50]'},{name: 'password',display: 'Password',rules: 'trim|required|min_length[8]|max_length[20]'},{name: 'password_confirm',display: 'Confirm Password',rules: 'trim|required|matches[password]'},{name: 'street',display: 'Street',rules: 'trim|required|min_length[1]|max_length[50]'},{name: 'housenumber',display: 'House No.',rules: 'trim|required|alpha_numeric|min_length[1]|max_length[5]'},{name: 'addition',display: 'Addition',rules: 'trim|alpha_numeric|min_length[1]|max_length[4]'},{name: 'zipcode',display: 'Zip Code',rules: 'trim|required|alpha_numeric|exact_length[6]'},{name: 'city',display: 'City',rules: 'trim|required|alpha_numeric|min_length[1]|max_length[50]'},{name: 'neighborhood',display: 'Neighborhood',rules: 'trim|alpha_numeric|min_length[1]|max_length[50]'}], function(errors) { if (errors.length > 0) { var form = $('form[name="register-form"]'); form.find('.form-group.error').removeClass('error'); form.find('.form-group .error-text').html(''); // Show the errors $.each(errors, function(index, value) { var obj = $('[name=' + value.name + ']'); obj.closest('.form-group').addClass('error'); obj.next('.error-text').html(value.message); }); } }); });