Skip to content

Commit

Permalink
Merge pull request #817 from nicolas-eoxia/add_js_function
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-eoxia authored Jan 19, 2024
2 parents 750818e + a95b890 commit 9c72f66
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
23 changes: 22 additions & 1 deletion js/modules/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ window.saturne.utils.reloadField = function() {

$.ajax({
url: document.URL + querySeparator + "element_type=" + field + "&token=" + token,
type: "POST",
type: 'POST',
processData: false,
contentType: false,
success: function(resp) {
Expand All @@ -142,3 +142,24 @@ window.saturne.utils.reloadField = function() {
error: function() {}
});
};

/**
* Enforce min and max value on keyup event for field input
*
* @memberof Saturne_Utils
*
* @since 1.2.1
* @version 1.2.1
*
* @returns {void}
*/
window.saturne.utils.enforceMinMax = function(triggeredElement) {
if (triggeredElement.value !== "") {
if (parseInt(triggeredElement.value) < parseInt(triggeredElement.min)) {
triggeredElement.value = triggeredElement.min;
}
if (parseInt(triggeredElement.value) > parseInt(triggeredElement.max)) {
triggeredElement.value = triggeredElement.max;
}
}
};
Loading

0 comments on commit 9c72f66

Please sign in to comment.