为啥不给分,那俺也不写正则,哈<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<script type="text/javascript">
<!--
var vTextData = "";while (vTextData != "OK") // 在这里写校验函数!
{
vTextData = window.prompt("请输入 OK", "");
}
alert("Right, Go next step!");
//-->
</script>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<script type="text/javascript">
<!--
var vTextData = "";while (vTextData != "OK") // 在这里写校验函数!
{
vTextData = window.prompt("请输入 OK", "");
}
alert("Right, Go next step!");
//-->
</script>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>dhtml.window.prompt.html</title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
</head>
<body>
<script type="text/javascript">
<!--
var re = new RegExp("^\\d{11}$")var vUserInput = "";while (!re.test(vUserInput))
{
vUserInput = window.prompt("请正确输入 11 位手机号码", vUserInput);
}
alert("Right, Go next step!");
//-->
</script>
</body>
</html>
樓上的二位,不知你們有沒有辦法做到onkeyPress事件,只能輸入數字呢?就是在window.prompt的文本框中,按下某個字母鍵,該字母不顯示在文本框中;按下某數字鍵,該數字顯示在文本框中。
它会暂停所有监听!想要实现你说滴效果只能用div模拟了!