<%@ page contentType="text/html;charset=GBK" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>验证字符串中包含有效字符</title>
<script language="JavaScript">
<!--
var keyword = new Array(
				"[0-9]+", "BS", "RPWT", "YY"
				);

function checkdata() {
	var txt = document.forms[0].txt.value;
	if(txt == "") {
		alert("不能空");
		return false;
	}
	
	for(var i=0; i<keyword.length; i++) {
		if(txt.search(keyword[i])!=-1) {
			return true;
		}
	}
	
	alert("不包含有效字符");
	return false;
}
-->
</script>
</head>
<body>

<form action="action_checksubstr.jsp" method="post" OnSubmit="return checkdata()">
<p>请输入一非空字符串:<input type="text" name="txt">
<p><input type="submit" value="检查并提交">
<form>
</body>
</html>