Rectangle 27 8

In addition to the accepted answer(https://stackoverflow.com/a/22565376/790811), we should consider Zero-width_non-joiner (or in persian) characters too. Unfortunately we have 2 symbols for it. One is standard and the other is not standard but widely used :

So the final regix can be :

If you want to consider "space", you can use this :

^[\u0600-\u06FF\uFB8A\u067E\u0686\u06AF\u200C\u200F ]+$

you can test it JavaScript by this :

/^[\u0600-\u06FF\uFB8A\u067E\u0686\u06AF7\u200C\u200F ]+$/.test('   ')

You can ask your question in different thread

c# - regex for accepting only persian characters - Stack Overflow

c# asp.net regex unicode
Rectangle 27 3

attention: persianRex is written in Javascript however you can use the source code and copy paste the characters

Detecting Persian characters is a tricky task due to veraiety of keyboard layouts and operating systems. I faced the same challenge sometime before and I decided to write an open source library to fix this issue.

you can fix your issue like this: persianRex.text.test(yourInput); //returns true or false

c# - regex for accepting only persian characters - Stack Overflow

c# asp.net regex unicode
Rectangle 27 3

\p{Cyrillic}

The only way to do a strict multilingual validation in JavaScript is to list range of characters, e.g. \uxxxx-\uyyyy.

The Unicode Script syntax is simply implemented based on the data file by Unicode Consortium.

Using the Unicode Script syntax directly is convenient and make the code clean. However, you don't know what exactly is matched by the character class. You may use this chance to look at the list of characters and filter out whatever you don't want.

could you please modify yourdescdmask:/^[--\p{Cyrillic}0-9\s\-]{1,10}$/ to let it accept the mentioned languages? I couldn't find a solution, I will pray you everyday if you can fix it, :)

@user3150692 Don't make promises that you won't satisfy :)

@user3150692: I don't know which character Russian/Persian uses. Would you please check the list yourself?

@HamZa HAHA I'LL DO THAT, I am trying to figure it out for 15H already but no luck yet,

javascript - How to write a multilingual regex validation for Russian ...

javascript jquery regex
Rectangle 27 3

\p{Cyrillic}

The only way to do a strict multilingual validation in JavaScript is to list range of characters, e.g. \uxxxx-\uyyyy.

The Unicode Script syntax is simply implemented based on the data file by Unicode Consortium.

Using the Unicode Script syntax directly is convenient and make the code clean. However, you don't know what exactly is matched by the character class. You may use this chance to look at the list of characters and filter out whatever you don't want.

could you please modify yourdescdmask:/^[--\p{Cyrillic}0-9\s\-]{1,10}$/ to let it accept the mentioned languages? I couldn't find a solution, I will pray you everyday if you can fix it, :)

@user3150692 Don't make promises that you won't satisfy :)

@user3150692: I don't know which character Russian/Persian uses. Would you please check the list yourself?

@HamZa HAHA I'LL DO THAT, I am trying to figure it out for 15H already but no luck yet,

javascript - How to write a multilingual regex validation for Russian ...

javascript jquery regex
Rectangle 27 1

Set UTF-8 as the character set for all headers output by your PHP code

In every PHP output header, specify UTF-8 as the encoding:

  header('Content-Type: text/html; charset=utf-8');

javascript - PHP alert message in persian language - Stack Overflow

javascript php alert persian farsi
Rectangle 27 0

In your HTML file, <div id="#Seconds" style="font-size: 40px;"> is incorrect. The id should just be Seconds, without the #. The # prefix is your way of telling Jquery that Seconds is the id, as opposed to the class (which you prefix with .) or the type of tag (no prefix). But it's not part of the id itself.

javascript - Number of seconds Convert the Persian numbers - Stack Ove...

javascript jquery
Rectangle 27 0

Note that this site contains a lot of calenders to choose from and one of them is the Persian calender.

I means that how we can Convert DWTCalednar to persian (Hijri) Calendar!

oh! my apologies I'll check the code and then I will get back to you as soon as I can.

It needs a lot of work to convert it to Hijri format, why not using a Hijri calender instead? Like the one I provided, it saves you time and I assume it will serve your purpose.

Ok, DWTCalendar is using in Zimbra Collaboration Suite Web Client , i had to use DWT and i can't using any one.

I am afraid that you should develop on your own, I Googled this issue and I asked my colleague at work who has worked with Zimbra sometime ago, and he said there is no Hijri calender as he knows. EDIT Here are some articles I found that can help you with this kind of development, they are in C# but you can easily convert it to Javascript: codeproject.com/Articles/34192/HijriDateView-ASP-NET-Control codeproject.com/Articles/8838/ Good luck!

javascript - Hijri (Persian calendar) For DwtCalendar.js - Stack Overf...

javascript calendar zimbra dwt hijri
Rectangle 27 0

Put the range inside a character class like below.

^[\u06F0-\u06F90-9]+$

why are you using "u0F90-9" ?

@Hamid Count correctly. He is using \u06F0-\u06F9 and 0-9, exactly like you wanted.

@Hamid consider \u06F0-\u06F9 and 0-9 as separate parts. Regex engine also parses like this..

javascript - Regex for persian number - Stack Overflow

javascript regex
Rectangle 27 0

You can use a regular expression to find the parts of the HTML that are between '>' and '<' characters, and operate on those. This will prevent the code from processing the tag names and attributes (style, etc).

// Convert all English digits in a string to Arabic digit equivalents
public static string ToArabicNums(string src)
{
    const string digits = "";
    return string.Join("", 
        src.Select(c => c >= '0' && c <= '9' ? digits[((int)c - (int)'0')] : c)
    );
}

// Convert all English digits in the text segments of an HTML 
// document to Arabic digit equivalents
public static string ToArabicNumsHtml(string src)
{
    string res = src;

    Regex re = new Regex(@">(.*?)<");

    // get Regex matches 
    MatchCollection matches = re.Matches(res);

    // process in reverse in case transformation function returns 
    // a string of a different length
    for (int i = matches.Count - 1; i >= 0; --i)
    {
        Match nxt = matches[i];
        if (nxt.Groups.Count == 2 && nxt.Groups[1].Length > 0)
        {
            Group g = nxt.Groups[1];
            res = res.Substring(0, g.Index) + ToArabicNums(g.Value) +
                res.Substring(g.Index + g.Length);
    }

    return res;
}

This isn't perfect, since it doesn't check at all for HTML character specifiers outside of the tags, such as the construct &#<digits>; ( for , etc)to specify a character by Unicode value, and will replace the digits in these. It also won't process any extra text before the first tag or after the last tag.

Calling: ToArabicNumsHtml("<html><body><h1>I was born in 1988</h1></body></html>")
Result: "<html><body><h1>I was born in </h1></body></html>"

Use whatever code you prefer in ToArabicNums to do the actual transformation, or generalize it by passing in a transformation function.

javascript - Converting Arabic numerals to Arabic/Persian numbers in h...

javascript converter arabic digits
Rectangle 27 0

you can use this hijri calendar that support all jquery versions. i use these for persian Calendar.

javascript - Hijri (Persian calendar) For DwtCalendar.js - Stack Overf...

javascript calendar zimbra dwt hijri
Rectangle 27 0

You can use a meta tag for the HTML on which you want this alert, you have set the character set which is suitable for persian language. usually following works charset="UTF-8" if this doesn't work, use charset="ISO-8859-1"

javascript - PHP alert message in persian language - Stack Overflow

javascript php alert persian farsi
Rectangle 27 0

The way that you have set the rep object is good for selecting the numbers, you can split the value of sec variable and read the related property of the object. Note that you should use html instead of the text.

<div id="#Seconds" style="font-size: 40px;">
20
</div>
<div id="Seconds" style="font-size: 40px;">
&#1778;&#1776;
</div>
var rep = {
        '0': '&#1776;',
        '1': '&#1777;',
        '2': '&#1778;',
        '3': '&#1779;',
        '4': '&#1780;',
        '5': '&#1781;',
        '6': '&#1782;',
        '7': '&#1783;',
        '8': '&#1784;',
        '9': '&#1785;',
        ':': ':',
    }

var str = '';
var sec = 20;

var timer = setInterval(function() {   
    var sss = sec--;
    if (sss == -1) {
      clear();
    }
    if (sss < 10) {sss = "0" + sss.toString()}
    var v = sss.toString().split("");
    str = rep[v[0]].toString() + rep[v[1]].toString();        
    $('#Seconds').html(str);     
},1000);

function clear() {
   clearInterval(timer)
   alert('okay')    
}

javascript - Number of seconds Convert the Persian numbers - Stack Ove...

javascript jquery
Rectangle 27 0

Use regular expressions. Here is the JavaScript code I myself use:

function toIndic(n) {
    var ns = ['', '', '', '', '', '', '', '', '', ''];

    return n.toString().replace(/\d/g, function (m) { 
        return ns[m];
    });
}

To make sure, you only convert numbers, you can use a better regular expression: \b[0-9]+\b

H1

Parsing HTML with Regular expression is semi-acceptable if you know exact structure of HTML and need to pick very limited, well defined elements. it looks like @irsog wants generic code - regex is bad idea for that - stackoverflow.com/questions/1732348/

javascript - Converting Arabic numerals to Arabic/Persian numbers in h...

javascript converter arabic digits
Rectangle 27 0

This function can convert English to Persian , Arabic and ordu

function convertDigitIn(enDigit){ // PERSIAN, ARABIC, URDO
    var newValue="";
    for (var i=0;i<enDigit.length;i++)
    {
        var ch=enDigit.charCodeAt(i);
        if (ch>=48 && ch<=57
        {
            // european digit range
            var newChar=ch+1584;
            newValue=newValue+String.fromCharCode(newChar);
        }
        else
            newValue=newValue+String.fromCharCode(ch);
    }
    return newValue;
}

+0: you have correct function, but unfortunately if you read the question it is "how to find all text values in HTML and apply known transformation", has nothing to do with title...

javascript - Converting Arabic numerals to Arabic/Persian numbers in h...

javascript converter arabic digits
Rectangle 27 0

or can you provide me an example?

// Find text in descendents of an element, in reverse document order
// pattern must be a regexp with global flag
//
function findText(element, pattern, callback) {
    var nonHtmlTags= {textarea:1, option:1, script:1, style:1, svg:1, math:1};
    for (var childi= element.childNodes.length; childi-->0;) {
        var child= element.childNodes[childi];
        if (child.nodeType==1 && !(child.tagName in nonHtmlTags)) {
            findText(child, pattern, callback);
        } else if (child.nodeType==3) {
            var matches= [];
            var match;
            while (match= pattern.exec(child.data))
                matches.push(match);
            for (var i= matches.length; i-->0;)
                callback.call(window, child, matches[i]);
        }
    }
}

// Find text and wrap with span elements
//
function highlightText(element, pattern, className) {
    findText(document.body, pattern, function(node, match) {
        var span= document.createElement('span');
        span.className= className;
        node.splitText(match.index+match[0].length);
        span.appendChild(node.splitText(match.index));
        node.parentNode.insertBefore(span, node.nextSibling);
    });
}

highlightText(document.body, /[a-z]+/gi, 'english-word');
highlightText(document.body, /[\u0600-\u06FF]+/gi, 'persian-word');

Note the English and Persian regexps are very nave and will fail for unusual characters, like Latin or Arabic . Coming up with a more complete expression is left as an exercise for the abecedarian.

jquery - How can I display English and Persian words on a web page in ...

javascript jquery
Rectangle 27 0

Note that this site contains a lot of calenders to choose from and one of them is the Persian calender.

I means that how we can Convert DWTCalednar to persian (Hijri) Calendar!

oh! my apologies I'll check the code and then I will get back to you as soon as I can.

It needs a lot of work to convert it to Hijri format, why not using a Hijri calender instead? Like the one I provided, it saves you time and I assume it will serve your purpose.

Ok, DWTCalendar is using in Zimbra Collaboration Suite Web Client , i had to use DWT and i can't using any one.

I am afraid that you should develop on your own, I Googled this issue and I asked my colleague at work who has worked with Zimbra sometime ago, and he said there is no Hijri calender as he knows. EDIT Here are some articles I found that can help you with this kind of development, they are in C# but you can easily convert it to Javascript: codeproject.com/Articles/34192/HijriDateView-ASP-NET-Control codeproject.com/Articles/8838/ Good luck!

javascript - Hijri (Persian calendar) For DwtCalendar.js - Stack Overf...

javascript calendar zimbra dwt hijri
Rectangle 27 0

it sure take lot time since someone helped me to solve that issue, and then i forgot about it all, but i made a repository, so the important formula are there:

javascript - Date formula, Calculating Leap Year, Week, etc, in Persia...

javascript calendar date-arithmetic persian
Rectangle 27 0

Set UTF-8 as the character set for all headers output by your PHP code

javascript - PHP alert message in persian language - Stack Overflow

javascript php alert persian farsi
Rectangle 27 0

you can use this hijri calendar that support all jquery versions. i use these for persian Calendar.

javascript - Hijri (Persian calendar) For DwtCalendar.js - Stack Overf...

javascript calendar zimbra dwt hijri
Rectangle 27 0

After you downloaded the file, attach it to the head section of your html page.

<Head>
<script src="farsitype.js" type="text/javascript"></script>
<!-- Other tags are omitted to reduce complexity -->
</Head>

Now all you have to do is to create a text box and set its Lang attribute to "fa-IR".

<input type="textbox" name="text1" Lang="fa-IR" />
<asp:TextBox ID="txt_name" runat="Server" Lang="fa-IR" />

Load your page and it's done!

I'm glad that helps

Tnx Ali , Please create page on github and put your code there . i need english type script , but your work is so interesting , I decided writing thanks in comment segment. very thanks compatriot.

you're quite welcome, If you need any assistance please contact me via email. Ali_Rashidi_70@ymail.com

javascript - How to change TextBox input language to Persian as you ty...

javascript asp.net