H
H
hdtor2016-02-18 15:22:21
PHP
hdtor, 2016-02-18 15:22:21

How to check if a field is full?

I have a field in which tags (labels) are entered. Tags are entered in the following format: tag1, tag2, tag3
How can I check the legibility of the input? That is, if you entered: tag1, tag2, tag3 - everything is OK, and if you entered: tag1 tag2 tag3 - then an error - you entered the tags incorrectly, enter them separated by commas.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
W
wangler, 2016-02-18
@wangler

On the client, you can use input pattern="regex"
htmlbook.ru/html/input/pattern

S
Silm, 2016-02-18
@Silm

Then there can be 2 options: either there is a list of possible tags, or there can be no spaces in the tags.
In the first option, it is not necessary to let the user enter the text himself, let him click on the tags, and they are added without the possibility of editing their text.
In the second option, we can force all spaces to be replaced with commas. All the same, after all, there should not be spaces ... If it is necessary to give an error, then we google "form validation".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question