Validate Url For Multilingual - Japanese Langauga
Solution 1:
I think you should use form validator. For example, I prefer to use this one: http://jqueryvalidation.org/validate. You can write your own validation rules depending on language.
For exanple, this is how you can validate car VIN number:
(function() {
jQuery.validator.addMethod("vin", function(value, element) {
returnthis.optional(element) || /^[a-z0-9]{17}$/i.test(value);
}, "");
})();
Solution 2:
There is a very simple method to apply all you RegEx logic(that one can apply easily in English) for any Language using Unicode.
For matching a range of Unicode Characters like all Alphabets [A-Za-z] we can use
[\u0041-\u005A] where \u0041 is Hex-Code for A and \u005A is Hex Code for Z
'matchCAPS leTTer'.match(/[\u0041-\u005A]+/g)
//output ["CAPS", "TT"]
In the same way we can use other Unicode characters or their equivalent Hex-Code according to their Hexadecimal Order (eg: \u0A10 to \u0A1F) provided by unicode.org
Below is a regEx for url validation
url.match(/^(ht|f)tps?:\/\/[a-z0-9-\.]+\.[a-z]{2,4}\/?([^\s<>\#%"\,\{\}\\|\\\^\[\]`]+)?$/)
you just replace a-z, A-Z, 0-9 with the similar characters from Japanese Unicode set and it will work fine. I don't know Japanese :)
Post a Comment for "Validate Url For Multilingual - Japanese Langauga"