代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>checkbox</title>
<meta name="description" content="">
<meta name="keywords" content="">
<link href="" rel="stylesheet">
</head>
<body>
<form>
<label>选中:</label><input type="text" onkeyup="funcChina()" >
</form>
<script type="text/javascript">
function funcChina(){
var obj = document.getElementsByTagName(‘input‘)[0].value;
var patthrn=/.*[\u4e00-\u9fa5]+.*$/;
if(patthrn.test(obj))
{
alert("不能含有汉字!");
return false;
}
}
</script>
</body>
</html>
时间: 2024-10-10 15:26:18