<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Javascript RegExp</title>
</head>
<script type="text/javascript">
function judge(){
try {
var parameter;
var regex='^([0-9]+)$';
var pp;
var flag=false;
parameter=document.getElementById("parameter").value;
pp=new RegExp(regex,'gi');
flag=pp.test(parameter);
document.getElementById("spanId").innerHTML=flag;
} catch (e) {
document.write('e.name='+e.name+',e.message='+e.message);
}
}
</script>
<body>
<div id="div1">
INPUT:<br/>
<input id="parameter" type="text" /><br/>
<input id="button" type="button" onclick="javascript:judge();" value="猛击我"/><br/>
</div>
<span id="spanId"></span>
</body>
</html>