Created
June 20, 2024 10:01
-
-
Save felipeabajo/d91fb8897ccfece7e15e076e6948e24c to your computer and use it in GitHub Desktop.
JS for checking special characters in a field of a form in a model driven Power App
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function CheckForSpecialCharacters(executionContext) { | |
'use strict'; | |
var formContext = executionContext.getFormContext(); | |
var StreetAddressField = formContext.getAttribute("crf8e_nombre").getValue(); | |
const specialChars = /[`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]/; | |
if (StreetAddressField === null) return; | |
if (specialChars.test(StreetAddressField)) { | |
formContext.getControl("crf8e_nombre").setNotification("The following characters are not allowed: [`!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?~]", 102); | |
return false; | |
} else { | |
formContext.getControl("crf8e_nombre").clearNotification(102); | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment