Verify that the Zhong Wenjing expression php and JavaScript

Source: Internet
Author: User
Tags php and



JavaScript form validation is Chinese, determines whether an input is Chinese and is implemented through regular expressions.
Check to see if it is Chinese

function Ischn (str) {
var reg =/^[u4e00-u9fa5]+$/;
if (!reg.test (str)) {
return false;
}
return true;
}

if (Escape (str). IndexOf ("%u")!=-1) alert ("contains Chinese characters"); else alert ("All characters");


Write it directly in the input.

<input onkeyup= "Value=value.replace (/[^u4e00-u9fa5]/g, ')" >

PHP Tutorials Validate Zhong Wenjing expressions

if (Escape (str). IndexOf ("%u")!=-1) alert ("contains Chinese characters"); else alert ("All characters");

<?php
$shouji = "haha haha";
if (!preg_match ("/^[x80-xff]{6,30}$/", $shouji)) {
echo "NoNoNo";
}
else {
echo "Yesyesyes";
}
?>


Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.