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() {
|
function addNewItem() {
|
||||||
if (isItemInputFilled()) {
|
if (isItemInputFilled()) {
|
||||||
let item = {
|
let item = {
|
||||||
name: $.selector_cache('#nameInput').val(),
|
name: sanitizeString($.selector_cache('#nameInput').val()),
|
||||||
description: $.selector_cache('#descriptionInput').val(),
|
description: sanitizeString($.selector_cache('#descriptionInput').val()),
|
||||||
quantity: $.selector_cache('#quantityInput').val(),
|
quantity: sanitizeNumber($.selector_cache('#quantityInput').val()),
|
||||||
price: $.selector_cache('#priceInput').val(),
|
price: sanitizeNumber($.selector_cache('#priceInput').val()),
|
||||||
code: $.selector_cache('#codeInput').val(),
|
code: $.selector_cache('#codeInput').val(),
|
||||||
type: getTypesChecked(),
|
type: getTypesChecked(),
|
||||||
image: $.selector_cache('#imageInput').val(),
|
image: $.selector_cache('#imageInput').val(),
|
||||||
|
@ -192,7 +192,13 @@ function saveDataset() {
|
||||||
SaveManager.saveData(currentTypes, currentDataset);
|
SaveManager.saveData(currentTypes, currentDataset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sanitizeString(str) {
|
||||||
|
return str.trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function sanitizeNumber(nbrStr) {
|
||||||
|
return nbrStr.replace(/\s/g,'');
|
||||||
|
}
|
||||||
|
|
||||||
function scanArticle(code) {
|
function scanArticle(code) {
|
||||||
let data = {
|
let data = {
|
||||||
|
|
Loading…
Reference in a new issue