Ei kuvausta
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.

modal-add-new-address.js 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * Add New Address
  3. */
  4. 'use strict';
  5. // Select2 (jquery)
  6. $(function () {
  7. const select2 = $('.select2');
  8. // Select2 Country
  9. if (select2.length) {
  10. select2.each(function () {
  11. var $this = $(this);
  12. $this.wrap('<div class="position-relative"></div>').select2({
  13. placeholder: 'Select value',
  14. dropdownParent: $this.parent()
  15. });
  16. });
  17. }
  18. });
  19. // Add New Address form validation
  20. document.addEventListener('DOMContentLoaded', function () {
  21. (function () {
  22. // initCustomOptionCheck on modal show to update the custom select
  23. let addNewAddress = document.getElementById('addNewAddress');
  24. addNewAddress.addEventListener('show.bs.modal', function (event) {
  25. // Init custom option check
  26. window.Helpers.initCustomOptionCheck();
  27. });
  28. FormValidation.formValidation(document.getElementById('addNewAddressForm'), {
  29. fields: {
  30. modalAddressFirstName: {
  31. validators: {
  32. notEmpty: {
  33. message: 'Please enter your first name'
  34. },
  35. regexp: {
  36. regexp: /^[a-zA-Zs]+$/,
  37. message: 'The first name can only consist of alphabetical'
  38. }
  39. }
  40. },
  41. modalAddressLastName: {
  42. validators: {
  43. notEmpty: {
  44. message: 'Please enter your last name'
  45. },
  46. regexp: {
  47. regexp: /^[a-zA-Zs]+$/,
  48. message: 'The last name can only consist of alphabetical'
  49. }
  50. }
  51. }
  52. },
  53. plugins: {
  54. trigger: new FormValidation.plugins.Trigger(),
  55. bootstrap5: new FormValidation.plugins.Bootstrap5({
  56. // Use this for enabling/changing valid/invalid class
  57. // eleInvalidClass: '',
  58. eleValidClass: '',
  59. rowSelector: '.form-control-validation'
  60. }),
  61. submitButton: new FormValidation.plugins.SubmitButton(),
  62. // Submit the form when all fields are valid
  63. // defaultSubmit: new FormValidation.plugins.DefaultSubmit(),
  64. autoFocus: new FormValidation.plugins.AutoFocus()
  65. }
  66. });
  67. })();
  68. });