Skip to content

Commit 1a5d8ea

Browse files
authored
Fix too permissive regular expression (#724)
The dot needs to be escaped due to its special meaning in regular expressions. Currently, both `j.doe` and `jXdoe` are considered valid, contrary to the task requirement that specifies that a single letter should be followed by a dot. I made this PR before (#710) but I accidentally closed that one.
1 parent e23fa55 commit 1a5d8ea

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

html/forms/tasks/form-validation/marking.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ The finished markup should look something like this:
4545

4646
Now we want you to take the same form you saw in the previous task (use your previous answer if you want to), and add some more specific pattern validation to the first three fields.
4747

48-
1. All of the user names in our application consist of a single letter, followed by a dot, followed by three or more letters or numbers. All letters should be lowercase. This will work — `pattern="[a-z]{1}.[a-z0-9]{3,}"`.
48+
1. All of the user names in our application consist of a single letter, followed by a dot, followed by three or more letters or numbers. All letters should be lowercase. This will work — `pattern="[a-z]{1}\.[a-z0-9]{3,}"`.
4949
2. All of the email addresses for our users consist of one or more letters (lower or upper case) or numbers, followed by "@bigcorp.eu". This will work — `[a-zA-Z0-9]+@bigcorp\.eu`.
5050
3. Remove the length validation from the phone number field if it is present, and set it so that it accepts 10 digits — either 10 digits in a row, or a pattern of three digits, three digits, then four digits, separated by either spaces, dashes, or dots. The following with work for this — `pattern="[0-9]{10}|[0-9]{3}[-. ][0-9]{3}[-. ][0-9]{4}"` — although bear in mind that it will work if the separators are not all the same (e.g. one dot and two dashes). This is OK for the purposes of this task — you'd be unlikely to get people entering numbers like this anyway, and it would be easy to sanitize the data on the server.
5151

@@ -60,7 +60,7 @@ The finished markup should look something like this:
6060
<li>
6161
<label for="uname">User name:</label>
6262
<input type="text" name="uname" id="uname" required
63-
pattern="[a-z]{1}.[a-z0-9]{3,}">
63+
pattern="[a-z]{1}\.[a-z0-9]{3,}">
6464
</li>
6565
<li>
6666
<label for="email">Email address:</label>

0 commit comments

Comments
 (0)