[英]Password in confirm box Javascript
我的 PHP 頁面中有一個刪除按鈕,用於刪除記錄。 但是當我刪除那個按鈕時,我做了一個確認框:
<form action="log.php" method="post" onsubmit="return confirm('Are you sure?');">
當他們確認必須填寫密碼時,我可以這樣做嗎?
所以我的意思是這樣的
<form action="log.php" method="post" onsubmit="return confirm('password :');">
然后他們必須填寫密碼
提前致謝。
嗨,您需要這樣的東西,根據您的要求進行修改
<script>
function do_check()
{
var return_value=prompt("Password:");
if(return_value==="your_password")
return true;
else
return false;
}
</script>
<form action="log.php" method="post" onsubmit="return do_check();">
嘗試使用input type="password"
, required
屬性`; 禁用提交直到密碼設置
document.forms["form"].querySelector("input[type=button]").onclick = function(e) { e.preventDefault(); this.nextElementSibling.disabled = false; this.nextElementSibling.nextElementSibling.disabled = false; }
<form name="form"> <input type="button" value="Are you sure?" /> <input type="password" minlength="3" maxlength="7" required disabled /> <input type="submit" disabled /> </form>
document.forms["form"].querySelector("input[type=button]").onclick = function(e) { e.preventDefault(); this.nextElementSibling.disabled = false; this.nextElementSibling.nextElementSibling.disabled = false; }
<form name="form"> <input type="button" value="Are you sure?" /> <input type="password" minlength="3" maxlength="7" required disabled /> <input type="submit" disabled /> </form>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.