Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug:https://github.com/VLCTechHub/VLCTechHub-site/issues/95 #112

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions data/assets/js/job-new.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ Site.Job.New.init = function() {
return false
}

function removeWhiteSpaces(event) {
let rgxMoney = /^[$]?([0-9]{1,3}.([0-9]{3}.)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?$|([0-9]{1,3}.([0-9]{3}.)*[0-9]{3}|[0-9]+)(.[0-9][0-9])?k/
let valueMoney = event.target.value
if (!rgxMoney.test(valueMoney)) {
$E('#new-job #salary').value = ''
}
}

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!

}