-
Notifications
You must be signed in to change notification settings - Fork 359
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release-10.1' into dev
- Loading branch information
Showing
17 changed files
with
124 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* global VuFind, isPhoneNumberValid */ | ||
|
||
VuFind.register('validation', function Validation() { | ||
/** | ||
* Check field match validity | ||
* @param {Event} ev Event | ||
* @returns {boolean} Validity | ||
*/ | ||
function checkMatchValidity(ev) { | ||
const field = ev.target; | ||
const matchSelector = field.dataset.match; | ||
if (!matchSelector) { | ||
return true; | ||
} | ||
const matchEl = field.form.querySelector(matchSelector); | ||
if (matchEl.value !== field.value) { | ||
field.setCustomValidity(field.dataset.matchError || ''); | ||
return false; | ||
} | ||
field.setCustomValidity(''); | ||
return true; | ||
} | ||
|
||
/** | ||
* Check field phone number validity | ||
* @param {Event} ev Event | ||
* @returns {boolean} Validity | ||
*/ | ||
function checkPhoneNumberValidity(ev) { | ||
const field = ev.target; | ||
if (field.id && field.type === 'tel' && field.dataset.validatorRegion) { | ||
const valid = isPhoneNumberValid(field.value, field.dataset.validatorRegion); | ||
if (true !== valid) { | ||
field.setCustomValidity(typeof valid === 'string' ? valid : VuFind.translate('libphonenumber_invalid')); | ||
return false; | ||
} | ||
} | ||
field.setCustomValidity(''); | ||
return true; | ||
} | ||
|
||
/** | ||
* Check field validity | ||
* @param {Event} ev Event | ||
*/ | ||
function checkValidity(ev) { | ||
const checks = [checkMatchValidity, checkPhoneNumberValidity]; | ||
for (const check of checks) { | ||
if (!check(ev)) { | ||
return; | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* Init custom form validation | ||
*/ | ||
function init() { | ||
document.addEventListener('input', checkValidity); | ||
} | ||
|
||
return { | ||
init: init | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.