0

How can I implement an input field mask for JForms in my component? Specifically I want a phone number mask something like ()-____. I only want users to enter digits and not have them enter parenthesis or dash. I also don't want to store the phone number with the parenthesis or dash.

0

Create your own field type to display custom content in your field.

https://docs.joomla.org/Creating_a_custom_form_field_type

While creating your own field type, you may want to extend the existing form fields functionality. text field is one such option in your case:

https://docs.joomla.org/Text_form_field_type

You can add client side validations using jQuery plugin like "jQuery validations"

https://jqueryvalidation.org/

  • I've been using custom fields for drop-down lists and such. I assume from your answer that there is no built-in functionality to mask an input field for things such as phone numbers, dates, id numbers, etc.? I guess that means that I have to code it. Any idea where I can find open-source code I could use? – nimble Aug 8 '16 at 18:09
  • Yes, there is no built-in option to mask the input for phone numbers etc. You can use the code mentioned in the above documentation. It has pretty much full code which you need. – Nagarjun Aug 8 '16 at 18:53

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.