Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jQuery("form#adminForm, form#userForm").on("submit", function(event) {
- var isTva = true;
- var inputsTva = jQuery('form#adminForm #pluginistraxx_euvatchecker_field');
- // define reg part, each country code has match different quantifier
- // for example, GB matches the characters GB literally (case sensitive), matches a digit 0-9, Matches exactly 5 times
- 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;
- //bind each related tva input, if not pass reg, return false
- jQuery.each(inputsTva, function(){
- if(!regTva.test(jQuery(this).val())) {
- isTva = false;
- }
- });
- // if return false disable submit button and alert message
- if (!isTva) {
- event.preventDefault();
- alert('PLease fill in correct TVA numbers.');
- jQuery(this).prop('disabled', true);
- }else {
- jQuery(this).prop('disabled',false);
- }
- });
Add Comment
Please, Sign In to add comment