1

How to check if the visitor entered any Arabic numbers like (۱, ۲, ۳)

Example: "Hi ۱ Sir, OK ۲ ۳ Thanks" in the "Text field" or "Text area" using C# (MVC or Core) or by using SQL Server Stored Procedure?

Note that I send the value via API using Ajax to the Controller, so I can process it in C# or send it to SQL Server Procedure to check it, and if it has Arabic numbers then return True or False.

I found many solutions in JavaScript but the visitor can pass it easily in browser console:

checkAR = function(){return false};

Please Advise.

fiverbox.com
  • 119
  • 9
  • 1
    This was already asked before plea check it here [How to Detect Arabic or Persian character in string by c#?](https://stackoverflow.com/a/45961993/8795884). – tontonsevilla Aug 10 '20 at 11:05

1 Answers1

1

for C#

static bool CheckArabicWords(string arabicText)
        {
            Regex regex = new Regex("[\u0600-\u06FF]");
            return regex.IsMatch(arabicText);

        }

for sql

Create Function [dbo].[IsArabic] (@text varchar(max))
Returns bit
as
begin
if(@text like '%[أ-ي]%')
return 1;
return 0;
end
Tariq Hajeer
  • 308
  • 2
  • 14