<html>
<head>
<script>
window.onload = function(){
}
function check() {
var bt = document.getElementById("bt");
var key = event.keyCode;
if (key == 13)
bt.click();
}
function test() {
var txtValue = document.getElementById("txt").value;
alert(txtValue);
}
</script>
</head>
<body>
<input type="text" id="txt" value="" onkeypress="return check()" />
<input type="button" id="bt"value="确 定" onclick="test()">
</body>
</html>
<head>
<script>
window.onload = function(){
}
function check() {
var bt = document.getElementById("bt");
var key = event.keyCode;
if (key == 13)
bt.click();
}
function test() {
var txtValue = document.getElementById("txt").value;
alert(txtValue);
}
</script>
</head>
<body>
<input type="text" id="txt" value="" onkeypress="return check()" />
<input type="button" id="bt"value="确 定" onclick="test()">
</body>
</html>