How do i set minimum number of text in a form. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do i set minimum number of text in a form.

How

8th Apr 2019, 2:10 PM
King Solomon
King Solomon - avatar
4 Answers
+ 1
What about if i want it to be at least 5 characters
8th Apr 2019, 6:22 PM
King Solomon
King Solomon - avatar
+ 2
<input type="text" maxlength="5"/> You can set maximum length that input can accept using maxlength attribute which the input tag accepts only that particular characters
8th Apr 2019, 2:39 PM
Deepak
Deepak - avatar
+ 2
You can use the pattern attribute with a regular expression to validate input with. i.e. <input pattern=”[A-Za-z]{5,}”/> This pattern allows A-Z and doesnt validate unless there are atleast 5 characters. For more, read up on regular expressions. Hope it helped.
8th Apr 2019, 6:52 PM
Victor Andersson
Victor Andersson - avatar
0
<input type="number" min="5" max="8"> You can aslo set minimum characters to be accepted by using above example
9th Apr 2019, 1:28 AM
Deepak
Deepak - avatar