[英]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.