1b.app
Link copied -

EVALUATE Improvement: Filling of fields in the form with type Number and fields according to the given mask.

Please rate the following revision, each part separately

Part 1

It is necessary that for fields with types:

- Number,

- A floating point number,

when we fill in the data in it, a keyboard with the numbers 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 was displayed, when clicking on which such a number will be added to the field.

It will be possible to enter any number of consecutive numbers, including those separated by a comma or a period according to the condition of filling the field with type Floating point number

Part 2

It is necessary that for fields with the type:

- Phone,

- email,

- String, etc., it was possible to set an input mask.

For example, for a phone, the mask can be as follows:

+99(999)999-99-99,

where 9 is a replacement digit from those we enter.

That is, when we fill in such a field, we have a numeric keyboard and we can simply substitute numbers, commas (dots).

It would be great if you could choose a country from the available list for fields with the Phone type, as is already done on your site when a new box is registered, for example.

See screenshots.

For email, the mask can be as follows:

*@*.*

where * is any character that is acceptable for creating email addresses.

These functions need to work when the form is filled out:

- from a computer

- from a mobile device: smartphone, tablet, etc
Original question is available on version: ua Вячеслав Легеза

Answers:

there is an opportunity to insert scripts for the form, write yourself expressions in JS and you don’t need to modify anything
29.11.2023, 17:15
Original comment available on version: ru

Легеза Вячеслав iCOLOR OneBox
ФОП Легеза В.В.
Personal license
Leave a message in this thread and the user's contacts will be shown to you

Ustimenko Igor
OneBox production wrote:
there is an opportunity to insert scripts for the form, write yourself expressions in JS and you don't need to refine anything

and can you give an example of such a script to enter the phone?
I will be very grateful for your help
29.11.2023, 17:48
Вячеслав Легеза Original comment available on version: ua

Легеза Вячеслав iCOLOR OneBox
ФОП Легеза В.В.
Personal license
Leave a message in this thread and the user's contacts will be shown to you


Legeza Vyacheslav

iCOLOR OneBox (FOP LEGEZA VIACHESLAV VALERIANOVYCH) wrote:



Ustimenko Igor

OneBox production wrote:

there is an opportunity to insert scripts for the form, write yourself expressions in JS and you don't need to refine anything



and can you give an example of such a script to enter the phone?

I will be very grateful for your help



This is the code suggested by artificial intelligence

***

const mask = "+99(999)999-99-99";

const input = document.querySelector("#phone");

// Set the mask for the input field

input.addEventListener("input", (e) => {

let value = e.target.value;

value = value.replace(/[^0-9\.]/g, "");

value = value.replace(/\./g, "-").replace(/\(/g, "").replace(/\)/g, "");

e.target.value = mask.replace(/9/g, value);

});

***

Tell me, please. how can you check?

Where should you paste this code to make it work
29.11.2023, 17:58
Вячеслав Легеза Original comment available on version: ua



Legeza Vyacheslav

iCOLOR OneBox (FOP LEGEZA VIACHESLAV VALERIANOVYCH) wrote:



Legeza Vyacheslav

iCOLOR OneBox (FOP LEGEZA VIACHESLAV VALERIANOVYCH) wrote:



Ustimenko Igor

OneBox production wrote:

there is an opportunity to insert scripts for the form, write yourself expressions in JS and you don't need to refine anything



and can you give an example of such a script to enter the phone?

I will be very grateful for your help



This is the code suggested by artificial intelligence

***

const mask = "+99(999)999-99-99";

const input = document.querySelector("#phone");

// Set the mask for the input field

input.addEventListener("input", (e) => {

let value = e.target.value;

value = value.replace(/[^0-9\.]/g, "");

value = value.replace(/\./g, "-").replace(/\(/g, "").replace(/\)/g, "");

e.target.value = mask.replace(/9/g, value);

});

***

Tell me, please. how can you check?

Where should you paste this code to make it work



in the gear on the right there is a design setting and there insert

alas, they will check the code you gave me, I won’t) try to figure it out yourself
29.11.2023, 18:37
Original comment available on version: ua

Please join the conversation. If you have something to say - please write a comment. You will need a mobile phone and an SMS code for identification to enter. Log in and comment