Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to apply textInput events in javascript

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to apply textInput events in javascript". The editor shows you the operation process through an actual case. The operation method is simple, fast and practical. I hope this article "how to apply textInput events in javascript" can help you solve the problem.

The code is as follows:

TextInput Event Example

This example only works in browsers that support the textInput event.

Var textbox = document.getElementById ("myText")

EventUtil.addHandler (textbox, "textInput", function (event) {

Event = EventUtil.getEvent (event)

Alert (event.data)

});

In this example, the characters inserted into the text box are displayed through a warning box.

In addition, there is a property on the event object, called inputMethod, that represents how the text is entered into the text box.

0, indicating that the browser is not sure how it was typed.

1, indicating that it was typed using the keyboard.

2, indicating that the text is pasted in.

3, indicating that the text was dragged and dropped in.

4, indicating that the text was entered using IME.

5, indicating that the text is entered by selecting an item in the form.

6, indicating that the text is entered by hand (such as using a stylus).

7, indicating that the text is entered by voice.

8, indicating that the text is entered in a combination of several ways.

9, indicating that the text was entered through a script.

Use this property to determine how the text is entered into the control, thus verifying its validity. Browsers that support textInput attributes are IE9+, Safari, and Chrome. Only IE supports the inputMethod attribute.

This is the end of the introduction to "how to apply textInput events in javascript". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report