0

I want to hide device keyboard forcefully on click event of a button for both android and ios using javaScript.

Problem is, if textbox has focus and user clicks on a button, then we need to hide device keyboard and show a custom popup.

Rupesh
  • 444
  • 3
  • 11
Anup
  • 3,105
  • 1
  • 24
  • 36
  • 1
    Have you looked at http://stackoverflow.com/questions/8335834/how-can-i-hide-the-android-keyboard-using-javascript/11160055#11160055 ? (My answer to this question works fine for me) – QuickFix Jul 18 '14 at 13:06
  • it is working fine thanks a lot .... now same thing trying for ios also hope it will work. – Anup Jul 22 '14 at 13:22
  • These are not working any other solution – Anup Sep 10 '14 at 10:10

1 Answers1

1

If no text input has the focus then the keyboard will close itself. You can set on your button onlick event an other event to change the focus without stopping the event (don't call event.preventDefault())

neomega
  • 704
  • 5
  • 17
  • i only use on click function no any event.preventDefault(); and i need to close device keyboard by code when i clicked on my function that time cursor present on that textbox. – Anup Jul 18 '14 at 12:45
  • Explain your conditions because from what i know, the button should take the focus if you don't call event.preventDefault() on your onclick function – neomega Jul 18 '14 at 12:51
  • keyboard goes slow in android tablets and all the code run before hiding it. I don't want to use setTimeout function for this problem. – Anup Jul 22 '14 at 13:23