gpt4 book ai didi

javascript - 通过 js 使 angular1 表单变脏

转载 作者:行者123 更新时间:2023-11-28 04:06:59 25 4
gpt4 key购买 nike

我正在将表单数据发送到登录名/密码,然后想要单击提交按钮,问题在于表单验证要求表单是脏的。我直接分配值,这意味着表单不被认为是脏的和修改的。我尝试过集中注意力,但似乎也不起作用。提交按钮不会出现,因为它未经验证。

document.getElementById("email").focus(); 
document.getElementById("password").focus();
var e = document.getElementById("email");
e.value = 'currentEmployee@email.com';
var p = document.getElementById("password");
p.value = 'currentEmployee.password';
var osbut = document.getElementById("loginForm"); osbut.submit();

我通过 chrome 扩展注入(inject)了一个脚本,并将其作为 content.js 脚本运行。如有任何帮助,我们将不胜感激。

最佳答案

只需将“在 Controller 表单中”设置为有效即可。例如:

$scope.formName.$valid=true;

关于javascript - 通过 js 使 angular1 表单变脏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46610796/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com