此區純粹筆記用 :p
只能輸入中英文與數字:
只能輸入中英文與數字:
rule ='^[0-9a-zA-Z\u4e00-\u9fa5]+$'
str = '只能輸入中文與English123345';
var regexp = new RegExp(rule);
console.log(regexp.test( str ));
rule ='^[0-9a-zA-Z\u4e00-\u9fa5]+$'
str = '只能輸入中文與English123345';
var regexp = new RegExp(rule);
console.log(regexp.test( str ));
function isChinese ( str ) { var regx = /[^\u4e00-\u9fa5]/; if ( regx.test( str ) ){ return false; } else { return true; } } alert(isChinese("中文"));
範例網址: http://jsfiddle.net/dNVDV/5/
<link href="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.css" rel="stylesheet" type="text/css"></link> <script src="http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js" type="text/javascript"> </script>
onload='prettyPrint();'
<pre class="prettyprint code"> 輸入想顯示的程式碼 </pre>
.post .code {
display: block;
font-family: Courier New;
font-size: 10pt;
overflow:auto;
background: #f3f3f3;
border: 1px solid #ddd;
padding: 10px 10px 10px 21px;
line-height: 1.2;
border-radius:3px;
}