@@ -244,6 +244,14 @@ To validate our form we will need to follow next steps:
244244 TODO: 2. Get value from field description and validate that it is not
245245 empty, has more then 2 characters, less then 250 characters and consist
246246 only from letters and numbers.
247+
248+ If you remember from before, you used the syntax
249+
250+ ` var onlyLetters = /^[A-z]+$/.test(value); `
251+
252+ to indicate that you only want letters. In order to define only numbers,
253+ you can add ` 0-9 ` inside the brackes, like ` [A-z0-9] ` . This allows any
254+ letter, and any number. You might want to allow spaces as well!
247255
248256 TODO: 3. Now in ` validateForm ` how to get errors from city and description
249257 field. For that we will have to change our variable ` error ` . It should be
@@ -252,11 +260,21 @@ To validate our form we will need to follow next steps:
252260
253261 ```
254262 var errors = {
255- name: nameValidation (name)
263+ name: nameValidationError (name)
256264 };
257265 ```
258-
266+
259267 TODO: 4. Now do same for city and description.
268+
269+ When you are defining multiple keys for an object, you need to add a comma
270+ to the previous value. For example:
271+
272+ ```
273+ var errors = {
274+ name: nameValidationError(name),
275+ city: cityValidationError(city)
276+ };
277+ ```
260278
261279 Now we are passing all of our errors into ` handleErrors ` function, but
262280 now we need to check if we have any errors differently. As we need iterate
@@ -329,10 +347,14 @@ To validate our form we will need to follow next steps:
329347 that we create for you in our ` index.css ` file. It only makes the border of the
330348 field that has this class red.
331349
332- TODO: 1.We will need to use ` querySelector ` to target the element on the page.
333- And all of it we can do inside our forEach loop. So we are targeting the whole
334- form and then fields with specific name (that our key will represent
335- ` [name="${key}"] ` ).
350+ TODO: 1.We will need to use ` document.querySelector ` to target the element on
351+ the page. And all of it we can do inside our forEach loop. So we are targeting
352+ the whole form and then fields with specific name (that our key will represent
353+ ` [name="${key}"] ` ). This will look like:
354+
355+ ```
356+ document.querySelector(`[name="${key}"]`)
357+ ```
336358
337359 TODO: 2.After we get our element on this element we need to add class ` .error ` .
338360 For that purpose we will use ` .classList.add('error') ` .
0 commit comments