Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

form-wizard.js 3.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. 'use strict';
  2. $(document).ready(function() {
  3. // $('#date,#datejoin').bootstrapMaterialDatePicker({
  4. // time: false,
  5. // clearButton: true
  6. // });
  7. // $("#example-date-inputS").bootstrapMaterialDatePicker({
  8. // time: false,
  9. // clearButton: true
  10. // });
  11. $("#basic-forms").steps({
  12. headerTag: "h3",
  13. bodyTag: "fieldset",
  14. transitionEffect: "slideLeft",
  15. autoFocus: true
  16. });
  17. $("#verticle-wizard").steps({
  18. headerTag: "h3",
  19. bodyTag: "fieldset",
  20. transitionEffect: "slide",
  21. stepsOrientation: "vertical",
  22. autoFocus: true
  23. });
  24. $("#design-wizard").steps({
  25. headerTag: "h3",
  26. bodyTag: "fieldset",
  27. transitionEffect: "slideLeft",
  28. autoFocus: true
  29. });
  30. var form = $("#example-advanced-form").show();
  31. form.steps({
  32. headerTag: "h3",
  33. bodyTag: "fieldset",
  34. transitionEffect: "slideLeft",
  35. onStepChanging: function(event, currentIndex, newIndex) {
  36. // Allways allow previous action even if the current form is not valid!
  37. if (currentIndex > newIndex) {
  38. return true;
  39. }
  40. // Forbid next action on "Warning" step if the user is to young
  41. if (newIndex === 3 && Number($("#age-2").val()) < 18) {
  42. return false;
  43. }
  44. // Needed in some cases if the user went back (clean up)
  45. if (currentIndex < newIndex) {
  46. // To remove error styles
  47. form.find(".body:eq(" + newIndex + ") label.error").remove();
  48. form.find(".body:eq(" + newIndex + ") .error").removeClass("error");
  49. }
  50. form.validate().settings.ignore = ":disabled,:hidden";
  51. return form.valid();
  52. },
  53. onStepChanged: function(event, currentIndex, priorIndex) {
  54. // Used to skip the "Warning" step if the user is old enough.
  55. if (currentIndex === 2 && Number($("#age-2").val()) >= 18) {
  56. form.steps("next");
  57. }
  58. // Used to skip the "Warning" step if the user is old enough and wants to the previous step.
  59. if (currentIndex === 2 && priorIndex === 3) {
  60. form.steps("previous");
  61. }
  62. },
  63. onFinishing: function(event, currentIndex) {
  64. form.validate().settings.ignore = ":disabled";
  65. return form.valid();
  66. },
  67. onFinished: function(event, currentIndex) {
  68. alert("Submitted!");
  69. $('.content input[type="text"]').val('');
  70. $('.content input[type="email"]').val('');
  71. $('.content input[type="password"]').val('');
  72. }
  73. }).validate({
  74. errorPlacement: function errorPlacement(error, element) {
  75. element.before(error);
  76. },
  77. rules: {
  78. confirm: {
  79. equalTo: "#password-2"
  80. }
  81. }
  82. });
  83. });