0

Here is my JavaScript:

jQuery.validator.addMethod("ChznCheck", function(val, elem) {
  return $(elem).val();
}, "Required before continuing");

jQuery.validator.setDefaults({
  errorElement: 'span',
  onkeyup: false,
  onclick: false,
  onfocusout: false,
  onsubmit: false,
  focusCleanup: true,
  ignore: [],
  rules: {
    "user[username]": {
      required: true,
      remote: {
        url: '/check_username',
        type: 'post',
        data: {
          username: function() {
            return $('#user_username').val();
          }
        }
      }
    },
    "user[state]": {
      ChznCheck: true
    }
  },
  messages: {
    "user[username]": "Username unavailable, please try again"
  }
});

$(function(){
  var $form, wizard;

  wizard = $('#registrationWizard').wizard();

  $form = $('#finalize-form');

  if ($form.length) {
    wizard.on('change', function(e, data) {
      log($form.validate().form());
      if (!$form.validate().form()) {
        return e.preventDefault();
      }
    }).on('finished', function(e) {
      return $form.submit();
    });
  }
})

I am using the fuel UX wizard (http://exacttarget.github.io/fuelux/#wizard) and I am using the Chosen library (http://harvesthq.github.io/chosen/) to "prettify" my select boxes. For some reason, when I get done filling out all fields in Step 1, and click Next, the form still fails, even though everything is filled out properly.

I am basically just trying to use the jQuery validation plugin (http://jqueryvalidation.org/) along with chosen to be able to validate my form, but am having no success. Anyone else run into this issue?

dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
  • I'm not posting this as an answer since it may not solve anything. However, it's a solid approach to using jQuery Validate plugin with a stepped form: http://stackoverflow.com/a/19098636/594235 – Sparky Oct 10 '13 at 18:49

1 Answers1

0

Found this pull request for the jQuery Validation Plugin: https://github.com/jzaefferer/jquery-validation/pull/452

dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189
  • But what's this have to do with Chosen?: _"I am basically just trying to use the jQuery validation plugin along with chosen to be able to validate my form, but am having no success"_ – Sparky Oct 10 '13 at 18:54