[英]Password in confirm box Javascript
I have a Delete button in my PHP page which deletes a record.我的 PHP 页面中有一个删除按钮,用于删除记录。 But when I delete that button I do a confirm box with:
但是当我删除那个按钮时,我做了一个确认框:
<form action="log.php" method="post" onsubmit="return confirm('Are you sure?');">
Can I make it so when they confirm they have to fill in a password?当他们确认必须填写密码时,我可以这样做吗?
So what I mean is something like this所以我的意思是这样的
<form action="log.php" method="post" onsubmit="return confirm('password :');">
And then they have to fill in a password然后他们必须填写密码
Thanks in advance.提前致谢。
Hi You Need some thing like this, Modify according to your requirements嗨,您需要这样的东西,根据您的要求进行修改
<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();">
Try usinginput type="password"
, required
attribute` ;尝试使用
input type="password"
, required
属性`; disable submit until password set禁用提交直到密码设置
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.