<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()">