Disabling Android Keyboard's 'Go' Button for WebView Text Entry

前端 未结 2 1037
清酒与你
清酒与你 2021-01-05 14:03

I am developing an Android application that uses a WebView pointed at a jQueryMobile-based site. Normally, disabling the \'Go\' button on the soft keyboard is as simple as a

相关标签:
2条回答
  • 2021-01-05 14:23

    Here's a more detailed answer that uses the method alluded to by Vikas.

    Since the problem is that your form is submitting, you can add an onSubmit attribute to your form element that runs JavaScript to determine if your form should be submitted.

    Below is the form that you don't want to submit:

    <form name="myForm" onSubmit="return doNothing()">
        <!-- Elements included in the form -->
    </form>
    

    And include this script that returns false which keeps your form from submitting.

    <script>
    function doNothing()
    {
        return false;
    }
    </script>
    

    Now, when you press Go after entering text into your text input field, the keyboard will simply collapse without submitting the form.

    This could also be used to check for errors in your form. See the webpage below: http://www.htmlcodetutorial.com/forms/_FORM_onSubmit.html

    0 讨论(0)
  • 2021-01-05 14:41

    You may stop submitting form by putting the onsubmit event of the form.

    0 讨论(0)
提交回复
热议问题