validate.tpl 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. {if !$hasRemoteInput}
  2. <script>
  3. var stateNotRequired = true,
  4. paymentForm = '';
  5. function validateBankAccountInput(e) {
  6. var newOrExisting = jQuery('input[name="paymethod"]:checked').val(),
  7. submitButton = jQuery('#btnSubmit'),
  8. submit = true,
  9. accountNumber = jQuery('#inputBankAcctNum');
  10. submitButton.prop('disabled', true).addClass('disabled').find('span').toggle();
  11. paymentForm.find('.form-group').removeClass('has-error');
  12. paymentForm.find('.field-error-msg').hide();
  13. if (newOrExisting === 'new') {
  14. var accountHolderName = jQuery('#inputBankAcctHolderName'),
  15. bankName = jQuery('#inputBankName'),
  16. routingNumber = jQuery('#inputBankRoutingNum');
  17. if (!accountHolderName.val()) {
  18. accountHolderName.showInputError();
  19. submit = false;
  20. }
  21. if (!bankName.val()) {
  22. bankName.showInputError();
  23. submit = false;
  24. }
  25. if (!routingNumber.val()) {
  26. routingNumber.showInputError();
  27. submit = false;
  28. }
  29. if (!accountNumber.val()) {
  30. accountNumber.showInputError();
  31. submit = false;
  32. }
  33. }
  34. if (!submit) {
  35. submitButton.prop('disabled', false)
  36. .removeClass('disabled')
  37. .find('span').toggle();
  38. e.preventDefault();
  39. }
  40. }
  41. jQuery(document).ready(function() {
  42. paymentForm = jQuery('#frmPayment');
  43. paymentForm.off('submit');
  44. paymentForm.on('submit', validateBankAccountInput);
  45. jQuery('.paymethod-info input[name="paymethod"]').on('ifChecked', function() {
  46. if (jQuery(this).val() === 'new') {
  47. showNewAccountInputFields();
  48. } else {
  49. hideNewAccountInputFields();
  50. }
  51. });
  52. jQuery('#billingAddressChoice input[name="billingcontact"]').on('ifChecked', function() {
  53. if (jQuery(this).val() === 'new') {
  54. showNewBillingAddressFields();
  55. } else {
  56. hideNewBillingAddressFields();
  57. }
  58. });
  59. paymentForm.find('#inputBankRoutingNum').payment('restrictNumeric');
  60. paymentForm.find('#inputBankAcctNum').payment('restrictNumeric');
  61. });
  62. </script>
  63. <script src="{$BASE_PATH_JS}/jquery.payment.js"></script>
  64. <script src="{$BASE_PATH_JS}/StatesDropdown.js"></script>
  65. {else}
  66. <script>
  67. jQuery(document).ready(function() {
  68. jQuery('.paymethod-info input[name="paymethod"]').on('ifChecked', function() {
  69. if (jQuery(this).val() === 'new') {
  70. if (window.location.toString().match(/\?/)) {
  71. window.location = window.location + '&ccinfo=new';
  72. } else {
  73. window.location = window.location + '?ccinfo=new';
  74. }
  75. return true;
  76. }
  77. });
  78. });
  79. </script>
  80. {/if}