|
6 | 6 | *
|
7 | 7 | * Dual licensed under the MIT or GPL Version 2 licenses
|
8 | 8 | *
|
9 |
| -* $version 1.5 |
| 9 | +* $version 1.5.1 |
10 | 10 | */
|
11 | 11 | (function($) {
|
12 | 12 | $.extend($.fn, {
|
|
29 | 29 |
|
30 | 30 | /**
|
31 | 31 | * Should be called on the element containing the input elements.
|
32 |
| - * <input data-help="The info that I want to display for the user when input is focused" ... /> |
| 32 | + * <input data-validation-help="The info that I want to display for the user when input is focused" ... /> |
33 | 33 | *
|
34 |
| - * @param {String} attrName Optional, default is data-help |
| 34 | + * @param {String} attrName Optional, default is data-validation-help |
35 | 35 | * @return {jQuery}
|
36 | 36 | */
|
37 | 37 | showHelpOnFocus : function(attrName) {
|
38 | 38 | if(!attrName) {
|
39 |
| - attrName = 'data-help'; |
| 39 | + attrName = 'data-validation-help'; |
40 | 40 | }
|
41 | 41 |
|
42 | 42 | var $el = $(this);
|
|
221 | 221 | return false;
|
222 | 222 | }
|
223 | 223 | });
|
224 |
| - if (!isChecked && $.inArray(radioButtonName, config.ignore) == -1) { |
225 |
| - errorMessages.push(language.requiredFields); |
| 224 | + |
| 225 | + if (!isChecked) { |
| 226 | + var validationErrorMsg = $el.attr(config.validationErrorMsgAttribute); |
| 227 | + $el.attr('data-validation-current-error', validationErrorMsg || language.requiredFields); |
| 228 | + errorMessages.push(validationErrorMsg || language.requiredFields); |
226 | 229 | errorInputs.push($el);
|
227 |
| - $(this).attr('data-error', language.requiredFields); |
228 | 230 | }
|
229 | 231 | }
|
230 | 232 | }
|
|
245 | 247 |
|
246 | 248 | if(valid !== true) {
|
247 | 249 | errorInputs.push($el);
|
248 |
| - $el.attr('data-error', valid); |
| 250 | + $el.attr('data-validation-current-error', valid); |
249 | 251 | addErrorMessage(valid);
|
250 | 252 | }
|
251 | 253 | }
|
|
292 | 294 | for (var i = 0; i < errorMessages.length; i++) {
|
293 | 295 | messages += '<br />* ' + errorMessages[i];
|
294 | 296 | }
|
295 |
| - // using div instead of P gives better control of css display properties |
| 297 | + // using div instead of P gives better control of css display properties |
296 | 298 | $form.children().eq(0).before('<div class="' + config.errorMessageClass + '">' + messages + '</div>');
|
297 | 299 | if(config.scrollToTopOnError) {
|
298 | 300 | $(window).scrollTop($form.offset().top - 20);
|
|
305 | 307 | var parent = errorInputs[i].parent();
|
306 | 308 | var errorSpan = parent.find('span[class=jquery_form_error_message]');
|
307 | 309 | if (errorSpan.length > 0) {
|
308 |
| - errorSpan.eq(0).text(errorInputs[i].attr('data-error')); |
| 310 | + errorSpan.eq(0).text(errorInputs[i].attr('data-validation-current-error')); |
309 | 311 | } else {
|
310 |
| - parent.append('<span class="jquery_form_error_message">' + errorInputs[i].attr('data-error') + '</span>'); |
| 312 | + parent.append('<span class="jquery_form_error_message">' + errorInputs[i].attr('data-validation-current-error') + '</span>'); |
311 | 313 | }
|
312 | 314 | }
|
313 | 315 | }
|
@@ -415,8 +417,7 @@ jQueryFormUtils.validateUKVATNumber = function(number) {
|
415 | 417 |
|
416 | 418 | var valid = false;
|
417 | 419 |
|
418 |
| - var VATsplit = []; |
419 |
| - VATsplit = number.split(""); |
| 420 | + var VATsplit = number.split(""); |
420 | 421 |
|
421 | 422 | var checkDigits = Number(VATsplit[7] + VATsplit[8]); // two final digits as a number
|
422 | 423 |
|
@@ -453,7 +454,7 @@ jQueryFormUtils.validateUKVATNumber = function(number) {
|
453 | 454 | // If not valid try the new method (introduced November 2009) by subtracting 55 from the mod 97 check digit if we can - else add 42
|
454 | 455 |
|
455 | 456 | if (!valid) {
|
456 |
| - total = total%97 // modulus 97 |
| 457 | + total = total%97; // modulus 97 |
457 | 458 |
|
458 | 459 | if (total >= 55) {
|
459 | 460 | total = total - 55
|
|
0 commit comments