Skip to content

Commit 9fecbe1

Browse files
committed
1 parent 6aadda7 commit 9fecbe1

File tree

11 files changed

+158
-135
lines changed

11 files changed

+158
-135
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ it calls jQ func **$.formUtils.validateInput** to validate the single input when
294294

295295
## Changelog
296296

297+
#### 3.1.36
298+
* Now possible to use the native reset() function to clear error messages and error styling of the input elements
299+
297300
#### 2.1.34
298301
* General improvements and bug fixes
299302
* Added events "beforeValidation" and "validation" (see http://formvalidator.net/#configuration_callbacks for more info)

form-validator/date.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/#location-validators
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.35
13+
* @version 2.1.36
1414
*/
1515
(function($) {
1616

form-validator/file.dev.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @website http://formvalidator.net/
1212
* @license Dual licensed under the MIT or GPL Version 2 licenses
13-
* @version 2.1.35
13+
* @version 2.1.36
1414
*/
1515
(function($, window) {
1616

form-validator/form-test.html

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,28 @@
4444
margin-left: 10px;
4545
}
4646

47+
span.help {
48+
color: #999 !important;
49+
}
50+
4751
</style>
4852
</head>
4953
<body>
5054
<div>
51-
<form action="" id="test-form" role="form">
55+
<form action="" id="form-a" role="form">
5256
<div class="form-group">
5357
<label class="control-label" for="inline-suggestions">Inline suggestions</label>
5458
<input name="inline suggestions" type="text" id="inline-suggestions" class="form-control" data-suggestions="Monkey, Horse, Fox, Tiger, Elephant" />
5559
</div>
5660

5761
<div class="form-group">
5862
<label class="control-label" for="country-suggestions">Country suggestions</label>
59-
<input name="country suggestions" type="text" id="country-suggestions" class="form-control" />
63+
<input name="country suggestions" data-validation="country" type="text" id="country-suggestions" class="form-control" />
6064
</div>
6165

6266
<div class="form-group">
6367
<label class="control-label" for="country-suggestions">Swedish county suggestions</label>
64-
<input name="Swedish county suggestion" type="text" id="swedish-county-suggestions" class="form-control" />
68+
<input name="Swedish county suggestion" data-validation="swecounty" type="text" id="swedish-county-suggestions" class="form-control" />
6569
</div>
6670

6771
<div class="form-group password-strength">
@@ -147,6 +151,29 @@
147151
</div>
148152
<p>
149153
<input type="submit" class="button">
154+
<input type="reset" class="button">
155+
</p>
156+
</form>
157+
<hr />
158+
<form id="form-b">
159+
<div class="form-group">
160+
<label class="control-label">Test</label>
161+
<input name="test" data-validation="number" type="text" />
162+
</div>
163+
<p>
164+
<input type="submit" class="button">
165+
<input type="reset" class="button">
166+
</p>
167+
</form>
168+
<hr />
169+
<form id="form-c">
170+
<div class="form-group">
171+
<label class="control-label">Country</label>
172+
<input name="test" data-validation="country" data-validation-error-msg="No valid country given" />
173+
</div>
174+
<p>
175+
<input type="submit" class="button">
176+
<input type="reset" class="button">
150177
</p>
151178
</form>
152179
</div>
@@ -169,21 +196,31 @@
169196
errorMessageKey: 'badEvenNumber'
170197
});
171198

172-
window.applyValidation = function() {
199+
window.applyValidation = function(validateOnBlur, forms, messagePosition) {
200+
if( !forms )
201+
forms = 'form';
202+
if( !messagePosition )
203+
messagePosition = 'top';
204+
173205
$.validate({
206+
form : forms,
174207
language : {
175208
requiredFields: 'Du måste bocka för denna'
176209
},
177-
errorMessagePosition : 'top',
210+
validateOnBlur : validateOnBlur,
211+
errorMessagePosition : messagePosition,
178212
scrollToTopOnError : true,
213+
borderColorOnError : 'purple',
179214
modules : 'security'+dev+', location'+dev+', sweden'+dev+', file'+dev+', uk'+dev,
180-
onModulesLoaded: function( $form ) {
215+
onModulesLoaded: function() {
181216
$('#country-suggestions').suggestCountry();
182217
$('#swedish-county-suggestions').suggestSwedishCounty();
183218
$('#password').displayPasswordStrength();
184219
},
185-
onValidate : function() {
186-
console.log('wii');
220+
onValidate : function($f) {
221+
222+
console.log('about to validate form '+$f.attr('id'));
223+
187224
var $callbackInput = $('#callback');
188225
if( $callbackInput.val() == 1 ) {
189226
return {
@@ -192,19 +229,21 @@
192229
};
193230
}
194231
},
195-
onError : function() {
232+
onError : function($form) {
196233
if( !$.formUtils.haltValidation ) {
197-
alert('Invalid');
234+
alert('Invalid '+$form.attr('id'));
198235
}
199236
},
200-
onSuccess : function() {
201-
alert('Valid');
237+
onSuccess : function($form) {
238+
alert('Valid '+$form.attr('id'));
202239
return false;
203240
}
204241
});
205242
};
206243

207-
window.applyValidation();
244+
window.applyValidation(true);
245+
window.applyValidation(false, '#form-b');
246+
window.applyValidation(true, '#form-c', 'element');
208247

209248
// Load one module outside $.validate() even though you do not have to
210249
$.formUtils.loadModules('date'+dev+'.js', false, false);

0 commit comments

Comments
 (0)