Guest User

Untitled

a guest
Jan 19th, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. jQuery("form#adminForm, form#userForm").on("submit", function(event) {
  2. var isTva = true;
  3. var inputsTva = jQuery('form#adminForm #pluginistraxx_euvatchecker_field');
  4. // define reg part, each country code has match different quantifier
  5. // for example, GB matches the characters GB literally (case sensitive), matches a digit 0-9, Matches exactly 5 times
  6. var regTva = /^(RO\d{2,10}|GB\d{5}|GBGD\d{3}|CHE\d{9}|CZ\d{8,10}|(ATU|DK|FI|HU|LU|MT|SI)\d{8}|IE[A-Z\d]{8}|(DE|BG|EE|EL|LT|BE0|PT)\d{9}|CY\d{8}[A-Z]|(ES|GB)[A-Z\d]{9}|(BE0|PL|SK|RU)\d{10}|(FR|IT|LV)\d{11}|(LT|SE)\d{12}|(NL|GB)[A-Z\d]{12})$;/g;
  7. //bind each related tva input, if not pass reg, return false
  8. jQuery.each(inputsTva, function(){
  9. if(!regTva.test(jQuery(this).val())) {
  10. isTva = false;
  11. }
  12. });
  13. // if return false disable submit button and alert message
  14. if (!isTva) {
  15. event.preventDefault();
  16. alert('PLease fill in correct TVA numbers.');
  17. jQuery(this).prop('disabled', true);
  18. }else {
  19. jQuery(this).prop('disabled',false);
  20. }
  21. });
Add Comment
Please, Sign In to add comment