diff --git a/EnvelopeGenerator.Web/appsettings.json b/EnvelopeGenerator.Web/appsettings.json index 28e6cbe9..cd250566 100644 --- a/EnvelopeGenerator.Web/appsettings.json +++ b/EnvelopeGenerator.Web/appsettings.json @@ -119,5 +119,17 @@ "AddedWho": "DDEnvelopGenerator", "ReminderTypeId": 202377, "EmailAttmt1": "" - } + }, + "Regexes": [ + { + "Pattern": "/^\\p{L}+(?:([\\ \\-\\']|(\\.\\ ))\\p{L}+)*$/u", + "Name": "City", + "Platforms": [ ".NET" ] + }, + { + "Pattern": "/^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$/", + "Name": "City", + "Platforms": [ "javascript" ] + } + ] } \ No newline at end of file diff --git a/EnvelopeGenerator.Web/wwwroot/js/annotation.js b/EnvelopeGenerator.Web/wwwroot/js/annotation.js index 555e9073..6d3fbd9c 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/annotation.js +++ b/EnvelopeGenerator.Web/wwwroot/js/annotation.js @@ -108,6 +108,8 @@ this.markFieldAsRequired(formFieldCity); + this.markFieldAsCity(formFieldCity); + /** * Date, post code and place label part */ @@ -307,6 +309,7 @@ return inch * 72 } + //required static #requiredFieldNames = new Array() static markFieldAsRequired(formField) { @@ -316,4 +319,15 @@ static isFieldRequired(formField) { return this.#requiredFieldNames.includes(formField.name) } + + //city + static #cityFieldNames = new Array() + + static markFieldAsCity(formField) { + this.#cityFieldNames.push(formField.name) + } + + static isCityField(formField){ + return this.#cityFieldNames.includes(formField.name) + } } \ No newline at end of file diff --git a/EnvelopeGenerator.Web/wwwroot/js/app.js b/EnvelopeGenerator.Web/wwwroot/js/app.js index a2c6ae9d..81a1717f 100644 --- a/EnvelopeGenerator.Web/wwwroot/js/app.js +++ b/EnvelopeGenerator.Web/wwwroot/js/app.js @@ -170,6 +170,8 @@ class App { async handleFinish(event) { const iJSON = await this.Instance.exportInstantJSON() const iFormFieldValues = await iJSON.formFieldValues; + + //check required const iReqFields = iFormFieldValues.filter(f => Annotation.isFieldRequired(f)) const hasEmptyReq = iReqFields.some(f => (f.value === undefined || f.value === null || f.value === "")) @@ -182,6 +184,20 @@ class App { return false; } + //check city + const city_regex = new RegExp("^[a-zA-Z\\u0080-\\u024F]+(?:([\\ \\-\\']|(\\.\\ ))[a-zA-Z\\u0080-\\u024F]+)*$") + const iCityFields = iFormFieldValues.filter(f => Annotation.isCityField(f)) + for(var f of iCityFields) + if(!city_regex.test(f.value)){ + Swal.fire({ + title: 'Warnung', + text: `Bitte überprüfen Sie die eingegebene Ortsangabe "${f.value}" auf korrekte Formatierung. Beispiele für richtige Formate sind: München, Île-de-France, Sauðárkrókur, San Francisco, St. Catharines usw.`, + icon: 'warning', + }) + return false; + } + + //check # of signature const validationResult = await this.validateAnnotations(this.signatureCount) if (validationResult === false) { Swal.fire({