Skip to content

Name your regex better #78

@otajor

Description

@otajor

Your regex here should not just be called regex. That doesn't give me as a code reviewer a lot of extra information.

It would be much better if you isolated it in its own function with a good name e.g.

function isSpecialCharacter(string) {
  return string.match('[?<>=+()*&^%$£@!#:;``~{}\[|_\\\]]')
}

form.addEventListener('keypress', function(e) {
  if (isSpecialCharacter(e.key)) {
    e.preventDefault();
  }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions