Skip to content

Commit

Permalink
Merge pull request #52 from peckadesign/51-validace-radio
Browse files Browse the repository at this point in the history
Oprava validací radio inputů
  • Loading branch information
zipper authored Apr 25, 2022
2 parents 7a38deb + ad34132 commit 17b0426
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "pd-forms",
"title": "pdForms",
"description": "Customization of netteForms for use in PeckaDesign.",
"version": "3.6.0",
"version": "3.6.1",
"author": "PeckaDesign, s.r.o <support@peckadesign.cz>",
"contributors": [
"Radek Šerý <radek.sery@peckadesign.cz>",
Expand Down
19 changes: 15 additions & 4 deletions src/assets/pdForms.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* @name pdForms
* @author Radek Šerý <radek.sery@peckadesign.cz>
* @version 3.6.0
* @version 3.6.1
*
* Features:
* - live validation
Expand Down Expand Up @@ -45,7 +45,7 @@

var pdForms = window.pdForms || {};

pdForms.version = '3.6.0';
pdForms.version = '3.6.1';


/**
Expand Down Expand Up @@ -142,7 +142,7 @@
* This function is not used when validating whole form, eg. by submit event.
*/
pdForms.liveValidation = function(e) {
var validate = [e.target];
var validate = e.target.type === 'radio' ? Array.from(e.target.form[e.target.name]) : [e.target];
var groupName = e.target.getAttribute('data-pdforms-validation-group');

if (groupName) {
Expand Down Expand Up @@ -672,7 +672,18 @@
var setEverFocused = function(e) {
var everFocused = e.target.getAttribute('data-pdforms-ever-focused');

if (! everFocused) {
if (everFocused) {
return;
}

if (e.target.type === 'radio') {
var radioList = e.target.form[e.target.name];

for (var i = 0; i < radioList.length; i++) {
radioList.item(i).setAttribute('data-pdforms-ever-focused', true);
}

} else {
e.target.setAttribute('data-pdforms-ever-focused', true);
}
}
Expand Down

0 comments on commit 17b0426

Please sign in to comment.