1 line
1.7 KiB
Plaintext
1 line
1.7 KiB
Plaintext
{"version":3,"file":"formfields.min.js","sources":["../../src/util/formfields.js"],"sourcesContent":["/**\n * Convert a text field into an integer only text field\n * @param {string} id The Id of the form field\n * @param {bool} unsigned Allow only unsigned values\n * @param {bool} nonzero Do not allow zero values\n */\nexport function textInteger(id, unsigned = false, nonzero = false) {\n const element = document.getElementById(id);\n\n if (element) {\n element.addEventListener(\"input\", () => {\n var val = element.value;\n if (val != '') {\n if ((isNaN(val) && !(!unsigned && val == '-')) || (unsigned && val < 0) || (nonzero && val == 0)) {\n // Set input value empty\n if (unsigned) {\n element.value = val.replace(/[^0-9]/g, '');\n if (nonzero && val == 0) {\n element.value = '';\n }\n } else {\n element.value = val.replace(/[^0-9-]/g, '').replace(/(.{1})(-)/g, '$1');\n }\n return false;\n } else {\n return true;\n }\n }\n return null;\n });\n }\n}"],"names":["id","unsigned","nonzero","element","document","getElementById","addEventListener","val","value","isNaN","replace"],"mappings":"mKAM4BA,QAAIC,iEAAkBC,sEACxCC,QAAUC,SAASC,eAAeL,IAEpCG,SACAA,QAAQG,iBAAiB,SAAS,SAC1BC,IAAMJ,QAAQK,YACP,IAAPD,MACKE,MAAMF,OAAWN,UAAmB,KAAPM,MAAiBN,UAAYM,IAAM,GAAOL,SAAkB,GAAPK,OAE/EN,UACAE,QAAQK,MAAQD,IAAIG,QAAQ,UAAW,IACnCR,SAAkB,GAAPK,MACXJ,QAAQK,MAAQ,KAGpBL,QAAQK,MAAQD,IAAIG,QAAQ,WAAY,IAAIA,QAAQ,aAAc,OAE/D,GAKR,IAAP"} |