Is it possible to enforce a numbers only input with a numerical minimum on a Text/Numeric price field? I'm guessing it could be done with jQuery, but I would rather have this set up in the Civi Admin UI, since it would be much cleaner.

More details:

I have a price field set up like this:

enter image description here

On the front end, it looks like this: (but I want 4 to be the lowest allowed number, with no letters input)

enter image description here

Basically, I want the HTML equal of <input type="number" min="4"/> in the cleanest and safest way possible. (safe as in not hacking up some jQuery and then moving an element 3 months later and breaking it)


Ideally you would develop a little extension that uses the validateForm hook (check https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_validateForm/). This will allow you to refuse input that does not meet your criteria.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.