1

Inside Android's webview, a from containing a textarea is processed by javascript. The problem: After submitting/processing the form, the Keyboard does not disappear, unless the user clicks outside.

I would like to make the keyboard disappear, right after form submission. How can this be achieved?

<form>
    <textarea>Hi there...</textarea>
</form>

<script>
   $("form").submit(function(){
      processForm();

      // I tried .blur() and .focusout(), which make the textarea loose focus, 
      // but the keyboard still does not hide...
      // $("textarea").blur();
      // $("textare").focusout();

      return false;       
   })
</script>
Elvis
  • 289
  • 4
  • 14
  • Have your checked this SO question:[link]http://stackoverflow.com/questions/8335834/how-can-i-hide-the-android-keyboard-using-javascript? – sinisha Mar 19 '14 at 08:29
  • I really searched, but didn't find this one. Will check it out... Thanks! – Elvis Mar 19 '14 at 08:32
  • Just tried all of the linked approaches, but none of them worked... – Elvis Mar 19 '14 at 09:29
  • Have you tried JavaScriptInterface solution calling Java code from the last answer at the link I provided to you? – sinisha Mar 19 '14 at 09:47
  • Check the possibilities in the link. https://stackoverflow.com/a/34548564/6584867 – NSetty Sep 10 '18 at 16:03

1 Answers1

1
$("form").reset();

Resetting the form should cause the keyboard to hide. Alternatively, you could try.

$('input').blur();
Michael
  • 430
  • 6
  • 20