1

I am sending form data to a login/password and then wanting to click the submit button, the problem is with the form validation requiring the form to be dirty. And I am directly assigning the values which means the form is not considered dirty and modified. I have tried focus but that doesn't seem to work either. The submit button won't appear because it isn't validated.

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();

I am injected a script via a chrome extension, running it as a content.js script. Any help is appreciated.

Hunter
  • 388
  • 4
  • 11
  • See examples that dispatch `change` event, or alternatively change the elements via document.execCommand 'insertText' – wOxxOm Oct 06 '17 at 17:18
  • Please post an answer so I can give you credit. It worked perfectly. Thankyou. I used document.execCommand 'insertText' – Hunter Oct 06 '17 at 17:38
  • Possible duplicate of following [question](https://stackoverflow.com/questions/29651931/how-to-setdirty-to-a-single-input) – Vignesh Oct 07 '17 at 15:22

2 Answers2

0

Just set In Controller Form as valid. For example:

$scope.formName.$valid=true;
Vivek Kodira
  • 2,764
  • 4
  • 31
  • 49
Sujith G
  • 1
  • 1
0

See examples that dispatch change event, or alternatively change the elements via document.execCommand 'insertText' – wOxxOm

This worked perfectly. I just wanted to close out the question. -Hunter

Hunter
  • 388
  • 4
  • 11