Sanitize fields before saving
This commit is contained in:
parent
4e1ec778c1
commit
3c089f5d16
1 changed files with 10 additions and 4 deletions
|
@ -89,10 +89,10 @@ function getItemOfCode(code) {
|
|||
function addNewItem() {
|
||||
if (isItemInputFilled()) {
|
||||
let item = {
|
||||
name: $.selector_cache('#nameInput').val(),
|
||||
description: $.selector_cache('#descriptionInput').val(),
|
||||
quantity: $.selector_cache('#quantityInput').val(),
|
||||
price: $.selector_cache('#priceInput').val(),
|
||||
name: sanitizeString($.selector_cache('#nameInput').val()),
|
||||
description: sanitizeString($.selector_cache('#descriptionInput').val()),
|
||||
quantity: sanitizeNumber($.selector_cache('#quantityInput').val()),
|
||||
price: sanitizeNumber($.selector_cache('#priceInput').val()),
|
||||
code: $.selector_cache('#codeInput').val(),
|
||||
type: getTypesChecked(),
|
||||
image: $.selector_cache('#imageInput').val(),
|
||||
|
@ -192,7 +192,13 @@ function saveDataset() {
|
|||
SaveManager.saveData(currentTypes, currentDataset);
|
||||
}
|
||||
|
||||
function sanitizeString(str) {
|
||||
return str.trim();
|
||||
}
|
||||
|
||||
function sanitizeNumber(nbrStr) {
|
||||
return nbrStr.replace(/\s/g,'');
|
||||
}
|
||||
|
||||
function scanArticle(code) {
|
||||
let data = {
|
||||
|
|
Loading…
Reference in a new issue