Skip to content

Commit 6de21ea

Browse files
committed
Changed attribute data-help to data-validation-help
1 parent 0d5930b commit 6de21ea

File tree

4 files changed

+22
-20
lines changed

4 files changed

+22
-20
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Since version 1.1 it is possible to display help information for each input. The
7474
<form action="" onsubmit="return $(this).validate();" id="my_form">
7575
<p>
7676
<strong>Why not:</strong>
77-
<textarea name="why" data-help="Please give us some more information" data-validation="required"></textarea>
77+
<textarea name="why" data-validation-help="Please give us some more information" data-validation="required"></textarea>
7878
</p>
7979
...
8080
</form>

example.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
99

1010
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
11-
<script type="text/javascript" src="jquery.formvalidator.min.js?upd=1.5"></script>
11+
<script type="text/javascript" src="jquery.formvalidator.min.js?upd=1.5.1"></script>
1212

1313
<link href="style.css?upd=1.5" type="text/css" rel="stylesheet"/>
1414

1515
</head>
1616
<body>
1717

1818
<h1>
19-
jQuery Form Validation (v 1.5)
19+
jQuery Form Validation (v 1.5.1)
2020
</h1>
2121
<p>
2222
<a href="https://github.com/victorjonsson/jQuery-Form-Validator/">
@@ -214,7 +214,7 @@ <h2>
214214

215215
<p>
216216
<strong>Domain</strong> <em>validate_domain</em><br/>
217-
<input type="text"id="testing" name="3" data-help="No protocol is needed" data-validation="validate_domain"/>
217+
<input type="text"id="testing" name="3" data-validation-help="No protocol is needed" data-validation="validate_domain"/>
218218
</p>
219219

220220
<p>

jquery.formvalidator.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Dual licensed under the MIT or GPL Version 2 licenses
88
*
9-
* $version 1.5
9+
* $version 1.5.1
1010
*/
1111
(function($) {
1212
$.extend($.fn, {
@@ -29,14 +29,14 @@
2929

3030
/**
3131
* 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" ... />
3333
*
34-
* @param {String} attrName Optional, default is data-help
34+
* @param {String} attrName Optional, default is data-validation-help
3535
* @return {jQuery}
3636
*/
3737
showHelpOnFocus : function(attrName) {
3838
if(!attrName) {
39-
attrName = 'data-help';
39+
attrName = 'data-validation-help';
4040
}
4141

4242
var $el = $(this);
@@ -221,10 +221,12 @@
221221
return false;
222222
}
223223
});
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);
226229
errorInputs.push($el);
227-
$(this).attr('data-error', language.requiredFields);
228230
}
229231
}
230232
}
@@ -245,7 +247,7 @@
245247

246248
if(valid !== true) {
247249
errorInputs.push($el);
248-
$el.attr('data-error', valid);
250+
$el.attr('data-validation-current-error', valid);
249251
addErrorMessage(valid);
250252
}
251253
}
@@ -292,7 +294,7 @@
292294
for (var i = 0; i < errorMessages.length; i++) {
293295
messages += '<br />* ' + errorMessages[i];
294296
}
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
296298
$form.children().eq(0).before('<div class="' + config.errorMessageClass + '">' + messages + '</div>');
297299
if(config.scrollToTopOnError) {
298300
$(window).scrollTop($form.offset().top - 20);
@@ -305,9 +307,9 @@
305307
var parent = errorInputs[i].parent();
306308
var errorSpan = parent.find('span[class=jquery_form_error_message]');
307309
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'));
309311
} 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>');
311313
}
312314
}
313315
}
@@ -415,8 +417,7 @@ jQueryFormUtils.validateUKVATNumber = function(number) {
415417

416418
var valid = false;
417419

418-
var VATsplit = [];
419-
VATsplit = number.split("");
420+
var VATsplit = number.split("");
420421

421422
var checkDigits = Number(VATsplit[7] + VATsplit[8]); // two final digits as a number
422423

@@ -453,7 +454,7 @@ jQueryFormUtils.validateUKVATNumber = function(number) {
453454
// 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
454455

455456
if (!valid) {
456-
total = total%97 // modulus 97
457+
total = total%97; // modulus 97
457458

458459
if (total >= 55) {
459460
total = total - 55

0 commit comments

Comments
 (0)