on ‎2022 Nov 30 5:12 PM
Hello, I'd like to add a prefix to an input field. This prefix should not be editable/selectable by the user i.e. the cursor should simply start at the end of this prefix. This is simply to let the user know how the final input will look like; for example, when creating an e-mail name some websites show the @domain.com behind the user's input. I want exactly that just in front of the input. Does anyone know how I would be able to achieve something like this? Every idea is much appreciated
Request clarification before answering.
I would say the Mask Input field is a good fit for what you are describing. Check out the code for the Product activation key field in the corresponding sample, this should be a good start.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Also, there seems to be a bug where the 'a' character is somehow seen as a maskformatSymbol? only happens with that character. Plus, when binding the mask to an object from a model and this value gets updated, the object value gets appended to the mask instead of replaced resulting in very weird behavior. Are you aware of this? If so, how can I fix this?
Hi Alex,
Unfortunately sap.m.MaskInput offers only fixed-length mask, so you cannot use it in cases where you need various-length input. For your use case you can use a combination of label and regular input, like in this snippet.
Also, inside you can find how to deal with small 'a' - it is not a bug - 'a' and '9' are default mask rules, where 'a' corresponds on regex "[A-Za-z]", and '9' corresponds on regex "[0-9]". If you want to use these symbols as immutable, you can escape them by prepending with ^ character, something like: mask: "^addon-xxxxxx".
For the problem with binding - I am not sure what is exact case, so can you provide some snippet that demonstrates the issue?
Best Regards
Nikolay Hristov
| User | Count |
|---|---|
| 13 | |
| 8 | |
| 7 | |
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.