Web effects detect whether the user name contains Chinese characters This verification code is more suitable for user registration verification, it can verify that the user entered the registered username that we do not want to appear in the string or Chinese characters, such as the following I defined letters as letters and numbers and _ lines, so that you can verify that the user submitted the database tutorial does not contain Chinese characters. */
function Checkifenglish (String) { var letters = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz1234567890_"; var i; var C; for (i = 0; i < string.length i + +) { c = String.charat (i); if (Letters.indexof (c) < 0) return false; } return true; }
var str = ' 122 China '; var str1 = ' FDAFSA_456776111CN '; if (Checkifenglish (str)) { Alert (' lawful username '); } Else { Alert (' String contains Chinese '); }
If (Checkifenglish (str1)) { alert (' Legal user name '); } Else { alert (contains Chinese in string); }
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.