0

I'm trying to create a simple multi step contact form that works well with screen readers and utilises the Jquery Validate plugin on each step.

I have a script that changes the focus and announces a new page for screen reader users which is working well. However, I'm having trouble working in a validation script. It's working on step 1 but is bypassed on steps 2 and 3.

There next button is also requiring two click instead of one. Can anyone tell me where I'm going wrong? Here's how I'm setting up the validation.

$(".next").click(function() {
var form = $("#contact-multi");
form.validate({
  errorClass: 'help-block',
  highlight: function(element, errorClass, validClass) {
    $(element).closest('.form-group').addClass("has-error");
  },
  unhighlight: function(element, errorClass, validClass) {
    $(element).closest('.form-group').removeClass("has-error");
  },
  errorPlacement: function(error, element) {
    if (element.prop('type') === 'radio' || element.prop('type') === 'checkbox') {
      error.insertBefore(element.parent());
    } else {
      error.insertBefore(element);
    }
  }
});
  if (form.valid() === true) { // If statement here?



  }
});

Work in progress here:

https://jsfiddle.net/ldigital/8b3rwobk/2/

okass
  • 81
  • 3
  • 8

2 Answers2

0

use form wizard and jquery validation plugins

0

Try to create each section in different forms & call .validate() for each form in different script tags.Try to validate form wise data.

Harjeet Singh
  • 388
  • 2
  • 6
  • 22