46
Views
7
Comments
Allow user to enter only those Special characters that are saved in database
Application Type
Reactive

Hi All,

I got a requirement where there are some Accent names with some special character like (&*@.,')  in database and when user is entering the text in inputbox I want to allow user to enter text 
+ number and if any special character then only those special characters or accent words are present in database  are allowed to enter in inputbox.

EG: If there are À, & in database then the user can enter hdcbGYY À & other then this special character are not allowed.

Is there anyway to resolve this issue. I have even shared the .oml file.

SpecialCharacter.oml

So, your expectation is, other that the alphanumeric only the special characters that are stored in database should be allowed. Am I missing something?


If the above case was the issue then you can validate the field using JS by using the below code,

function validateTextWithSpecialChars(inputText, allowedSpecialChars) {  const pattern = new RegExp(`^[A-Za-z${escapeRegExp(allowedSpecialChars)}]+$`);  return pattern.test(inputText);}function escapeRegExp(string) {  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');}$parameters.IsTextWithAllowedSpecialCharacters = validateTextWithSpecialChars($parameters.UserText, $parameters.SpecialCharacters)

here, the thing is you have to pass an input parameter which contains the special character you have stored in the database.

Hope it helps.

Hi Nandhakuma,

No, the user can enter alpha numeric text but if user wants to enter special characters or accent number

Eg: text:-  hdhe& is allowed cause & it is there in database

Text:- gigd* not allowed cause * sogn is not present in database.

Regards,

Vin j.

Really,

No one in the community has the idea of resolving this issue.


Regards,

Vin J.

Hi @Vin J,

Somehow, I've tried to solve your problem. The thing is, instead of storing the special characters in database, I've directly used the input box and a variable. kindly replace that with the database. other than that, it it's totally fine, I guess.

I've attached the OML take a look at it.

Hope it helps.

mySpecialCharacter.oml

Hi Nandhakumar S,

Thank you for your efforts but it didn't work like my requirement  mentioned above.

Regards,

Vin J.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.