I have a field in which I would like to force the user to enter two words separated by a space. If only one word is entered, it must not let the user submit the form.
<input type="text" name="nom"placeholder="Prenom Nom" required>
You could add a pattern
<input type="text" placeholder="Prenom Nom" required="required" pattern="^\S+\s\S+$" name="nom">
that matches any character group (but not space), a space, and any character group (but not space)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.