text: $(document).ready(function(){
    $.validator.addMethod(
            "regex",
            function(value, element, param) {
                var re = new RegExp(param);
                return this.optional(element) || re.test(value);
            },
            "Username minimal terdiri dari 3-25 karakter dan tidak boleh terdapat spasi."
    );
  
      $('.form-validate-jquery').validate({
          ignore: 'input[type=hidden], .select2-search__field', // ignore hidden fields
          errorClass: 'validation-invalid-label',
          successClass: 'validation-valid-label',
          validClass: 'validation-valid-label',
          highlight: function(element, errorClass) {
              $(element).removeClass(errorClass);
          },
          unhighlight: function(element, errorClass) {
              $(element).removeClass(errorClass);
          },
          // success: function(label) {
          //     label.addClass('validation-valid-label').text('Success.'); // remove to hide Success message
          // },
  
          // Different components require proper error label placement
          errorPlacement: function(error, element) {
  
              // Unstyled checkboxes, radios
              if (element.parents().hasClass('form-check')) {
                  error.appendTo( element.parents('.form-check').parent() );
              }
  
              // Input with icons and Select2
              else if (element.parents().hasClass('form-group-feedback') || element.hasClass('select2-hidden-accessible')) {
                  error.appendTo( element.parent() );
              }
  
              // Input group, styled file input
              else if (element.parent().is('.uniform-uploader, .uniform-select') || element.parents().hasClass('input-group')) {
                  error.appendTo( element.parent().parent() );
              }
  
              // Other elements
              else {
                  error.insertAfter(element);
              }
          },
          rules: {
              nik:{
                required:true
              },
              employee_name:{
                  required:true
              },
              position_id:{
                required:true
              },
              seksi_id:{
                required:true
              },
              bidang_id:{
                required:true
              },
              kcu_id:{
                required:true
              },
              cabang_id:{
                required:true
              },
              // password: {
              //     required:true,
              //     minlength: 5
              // },
              // password_confirm: {
              //     equalTo: '#password'
              // },
              email: {
                  email: true
              },
              username:{
                required:true,
                regex :'^[a-zA-Z0-9_-]{3,25}$'
              }
          },
          messages: {
              custom: {
                  required: 'This is a custom error message'
              },
              basic_checkbox: {
                  minlength: 'Please select at least {0} checkboxes'
              },
              styled_checkbox: {
                  minlength: 'Please select at least {0} checkboxes'
              },
              switchery_group: {
                  minlength: 'Please select at least {0} switches'
              },
              switch_group: {
                  minlength: 'Please select at least {0} switches'
              },
              agree: 'Please accept our policy'
          }
      });
  });
  