- From: Devon Govett <notifications@github.com>
- Date: Fri, 22 Jan 2021 11:32:32 -0800
- To: w3c/uievents <uievents@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <w3c/uievents/issues/289@github.com>
It would be very useful to have a way to determine what the value of an `<input>` element will be if `beforeinput` is not prevented. For example, when implementing validation of text entry (e.g. a number field, telephone field, credit card number, etc.), the `beforeinput` event can be used to invalid cancel invalid characters from being typed. However, especially with deletion `inputType`s, it can be challenging to get the full input value that would be committed after the `beforeinput` event. This is necessary in some cases to prevent deletion of certain parts of the input value. We can look at the selection and attempt to modify the existing value accordingly but this has many pitfalls, especially to do with unicode. For example, deletion by word or sentence is tricky to handle correctly. Plus, we shouldn't need to reinvent the code that the browser already has to do this. Perhaps the `InputEvent` could have a property that indicates what the value will be after it is applied in addition to the `data` that is inserted? Or maybe that belongs on the `HTMLInputElement` specifically, since I could see this being challenging to support for `contenteditable`? This issue is mainly a starting point for a conversation about this usecase, and I'm entirely open to any and all suggestions. 😄 -- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/w3c/uievents/issues/289
Received on Friday, 22 January 2021 19:32:44 UTC