2017-10-06 73 views
0

我發送表單數據到登錄名/密碼然後想要點擊提交按鈕,問題出在表單驗證要求表單變髒。我直接分配值,這意味着表格不被認爲是髒的和被修改的。我已經嘗試過重點,但似乎也沒有工作。提交按鈕不會出現,因爲它沒有被驗證。通過js使角1形式變髒

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

我通過chrome擴展插入腳本,將其作爲content.js腳本運行。任何幫助表示讚賞。

+0

查看調度'change'事件的示例,或者通過document.execCommand'insertText'更改元素 – wOxxOm

+0

請發佈一個答案,以便我可以給您信用。它工作完美。謝謝。我用document.execCommand'insertText' – Hunter

+0

下面的[question]可能重複(https://stackoverflow.com/questions/29651931/how-to-setdirty-to-a-single-input) – Vignesh

回答

0

請參閱分派改變事件的例子,或可替代地經由document.execCommand 'insertText' 改變元素 - wOxxOm

這完美地工作。我只想結束這個問題。 -Hunter

0

只需在控制器窗體中設置爲有效。例如:

$scope.formName.$valid=true;