<script language="JavaScript">
function test(){
var valid = checkColor('color');
if(valid==true){
window.open("www.sina.com");
}
}
function checkColor(object){
var pattern = /^[0-9]+$/
var obj = eval("document.all['" + object + "'].value") ;
if(obj.match(pattern)==null){
alert("错误");
return false;
}
else{
alert("正确");
return true;
}
}
</script>
<input type="text" name="color">
<input type="button" value="check" onclick="test()">
本文地址:http://com.8s8s.com/it/it31026.htm