8

I want to hide the keyboard on Focus(),but when $(".ui-input-text").focus(); it will automatically open the keyboard .

I just want to hide in particular screen ,I have test with document.activeElement.blur(); but it also did not focus() on input .

2
  • 1
    This seems perverse. You want to focus a user input field, but disable the input method? Why? Commented Dec 14, 2013 at 5:03
  • 3
    i have my custom keyboard on screen Commented Dec 14, 2013 at 5:04

4 Answers 4

14

When submitting a form, at times, the iOS Keyboard may not automatically close. This is quite a usability issue as Users should not be required to manually close the Keyboard for use-cases in which they would otherwise not expect the need do so.

A simple solution for this can be implemented by invoking the blur method on document.activeElement, which effectively allows one to programmatically hide the keyboard:

// automatically close the keyboard on iOS
document.activeElement.blur();

More about HTML5 and Mobile application events ..

http://www.ericfeminella.com/blog/2012/12/27/ios-html5-input-element-tips/

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

$('#yourElement').blur();

It will hide the virtual keyboard.

1 Comment

i have used this one but when i use it also not focus () on input
1

From here

var hideKeyboard = function() {
    document.activeElement.blur();
    $("input").blur();
};

Edited : another option

$('.clr').after('
        //<input tyep="checkbox" 
        <input type="checkbox"
               id="focusable" 
               style="height:0;
               margin- left:-200px;
               clear:both;" />');
$('#focusable').focus(); `

2 Comments

but issue was that when i add this code it also loose the focus from the input
@Gamex you can assing focus again as shown in another option.
1

Is this oversimplifying? :

<input id="x" inputmode="none" value="x">

I tangled with scripts for hours, and found this was a simpler and more reliable way to hide the keyboard when the input was being used for other stuff.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.