繁体   English   中英

文本框的背景色

[英]Background color of Text-box

我希望在文本框中单击“提交”按钮后,背景颜色至少保留5秒钟

但是一旦我单击“提交”按钮,它就会消失。

这是我的代码...

<!DOCTYPE>
<html>
<head>
<title>Text Boxes With Aplhabets </title>
</head>
<body>`enter code here`

<script type="text/javascript">

 frm.alphabets.value="";
function AllowAlphabets(){
               if (!frm.alphabets.value.match(/^[a-zA-Z]+$/) )
               {

                    frm.alphabets.focus(); 
                    frm.alphabets.style.background="Red";
                    //alert("Please Enter only alphabets");
               }

}      
</script>

<form name="frm"   onsubmit="return AllowAlphabets()">
Enter Aplhabets: <input type="text" name="alphabets" />
<input type = "submit" value = "Submit">
</form>
<br;>
</body>
</html>

使用setTimeout()

例如:

setTimeout(myFunction, 2000);

要么

setTimeout(function () {

//code here
}, 2000);

参考: MDN

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM