title: UIWebView - Autofill Email/Username field not working
body: <p>There're many posts on autofilling email/username and password fields in <code>UIWebView</code>, I tried all the ways possible but couldn't fill email/username field. However, filling password is working perfectly.</p>
  
  <p>Below is the code I've been dealing with so far.</p>
  
  <pre><code>// not working    
  NSString *loadUsernameJS = [NSString stringWithFormat:@"var inputFields = document.querySelectorAll(\"input[type='text']\"); \
    for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { 
      inputFields[i].value = '%@';
    }", savedUsername];
  
  // working!    
  NSString *loadPasswordJS = [NSString stringWithFormat:@"var passFields = document.querySelectorAll(\"input[type='password']\"); \
    for (var i = passFields.length&gt;&gt;&gt; 0; i--;) { 
      passFields[i].value ='%@';
    }", savedPassword];
  
  [self.webView stringByEvaluatingJavaScriptFromString: loadUsernameJS];
  [self.webView stringByEvaluatingJavaScriptFromString: loadPasswordJS];
  </code></pre>
  
  <p>I don't want to use <code>document.getElementById()</code> method as some websites accept email or username for login.</p>
  
  <p>I also have tried...</p>
  
  <pre><code>NSString *loadUsernameJS = [NSString stringWithFormat:@"var inputFields = document.getElementsByTagName('input'); \ for (var i = inputFields.length &gt;&gt;&gt; 0; i--;) { if(inputFields[i].name == 'username') inputFields[i].value = '%@';}", savedUsername];
  </code></pre>
  
  <p>But still no success.</p>