Assessment wanted for Form validation 1 skill test. (Tasks 1-3)

Assessment wanted for Form validation 1 skill test. (Tasks 1-3)

Link to task:

Links to my code:

Thanks :wink:

Great work, @EiN

Here are my comments:

  • Task 1: :white_check_mark: Correct.

  • Task 2: :warning: Some allowed patterns not valid.

    • Subtask 1: “m.1ko” should be allowed.
    • Subtask 2: “” should be allowed.
    • Subtask 3: Be aware that “\s” also includes other whitespaces like tabs, newlines and more.

    General comments for task 2:

    • ^ and $ are implied and don’t need to be written.
    • Multiple ranges can be combined without |: [a-zA-Z0-9] (letters and digits)
    • Same for multiple characters: (\s|\.|-) :arrow_right: [\s\.-]
  • Task 3: :white_check_mark: Correct. When comparing a boolean you can just leave out === true

Have a nice one,

1 Like

I suspected that I made a mistake in regular expressions. Now I have studied a little more and taken into account your comments, and it seems to have become clearer, in any case, at a basic level, understanding has already appeared.
Here is my corrected task-2 code:

Great improvements, @EiN!

Regexes are a powerful yet complicate concept. I hope you didn’t get frustrated :slightly_smiling_face:

I’m sure you’re glad to hear that there’s only one tricky little mistake left. I have also two simplifications:

  • There’s a special character for “one or more”: {1,} :arrow_right: +
  • The dot inside character classes (square brackets) loses its special meaning and can be written without backslash. (In my last post I missed that, too :sweat_smile: )
  • You will probably be surprised that the following phone number will work: 111(111&1111 . Can you find out why this is the case?
    Hint for the phone mistake Have a look at the ASCII table from 32 to 46.
    Solution for the phone mistake If we want to match a hyphen (`-`) in a character class, it has to be the first or last character. Otherwise it indicates a range. `[ -.]` means "all characters between space and dot". In ASCII these are all characters from 32 to 46. Correct character classes: [ .-] or [-. ]

Have a nice weekend,

1 Like


  • Regarding the special character “one or more”:
    Thank you for drawing my attention to it, for some reason I didn’t pay attention to it when viewing special characters, it’s really easier with it and the code looks simpler.

  • About my mistake with the phone:
    I’m even glad that I allowed it, since I could accidentally do the right thing and not pay attention to the fact that I could be wrong here.
    As soon as I looked at your remark and at my code, I immediately guessed what the problem was and after looking at your hint I was convinced of this.
    Initially, I thought that this could be solved with a backslash before the hyphen [ \-.].
    Then I took a look at your solution and applied it. My version is probably also working, but more complicated. And if there are a lot of such places in the code, it will add a lot of extra characters to the code.
    Here is my code after fix:

Once again I want to thank you for your help, it is priceless.

1 Like

Your changes are correct. :+1:

You’re right about [ \-.] also working. The backslash always removes the special meaning of the character. I haven’t thought about that, but I agree putting the hyphen at the end looks cleaner.