Skip to content

Conversation

@Eliandromeda
Copy link

Added validation with regular expression on salary field

Added validation with regular expression on salary field

let $form = $E('#new-job form')
$form.querySelector('button[data-type="submit"]').addEventListener('click', submitEvent)
$E('#new-job #salary').addEventListener('change', removeWhiteSpaces)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Elimystery, thanks for your contribution. In our site when creating a new job, we would like to force entering a value for salary, with a least a number on the text (I think your regular expression is matching something more concrete than that).

So values that are ok:

  • "10K"
  • "Entre 20.000 y 30.000"

Values that are not ok:

  • ""
  • "Según la experiencia del candidato"

In the site, we are not using javascript validations, but relying on html5 inputs instead. So we could use an input with a pattern and a title as shown here: https://webdesign.tutsplus.com/tutorials/html5-form-validation-with-the-pattern-attribute--cms-25145

In the project, they are created here: https://github.com/VLCTechHub/VLCTechHub-site/blob/master/templates/macros/form.njk#L1 and maybe we could create a patternTextInput component.

In this case, the value for the title would be "Introduce un rango salarial válido".

If you feel like trying that approach, feel free to contribute with this info in mind.
Thanks!

@esebastian esebastian force-pushed the main branch 2 times, most recently from b274155 to 47305eb Compare January 27, 2025 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants