Formatted Input Using Web Form...

User 91616 Photo


Registered User
27 posts

I have a form that requires a user to input their phone number. I'd like to have the user only enter numbers.
The form also requires ZIP code.
Is there a way to show the formatted input, i.e., (nnn) nnn-nnnn or nnnnn-nnnn in the input box, but have the user enter only the numbers?

Thanks.
User 91616 Photo


Registered User
27 posts

Clarification:
For example, the input for phone number would show: (nnn) nnn-nnnn
When the submitter clicks on the field or the cursor automatically enters the field, it would be on the first "n" and the submitter needs to only type numbers.
Same thing for the ZIP code.
I have already been provided the following code for the ZIP code field so thinking this might have to be incorporated into the formatting of the input: /(^\d{5}$)|(^\d{5}-\d{4}$)/
I have also been provided the following code for the phone number field so thinking this might also have to be incorporated into the formatting of the input: /(([01][\.\- +]\(\d{3}\)[\.\- +]?)|([01][\.\- +]\d{3}[\.\- +])|(\(\d{3}\) ?)|(\d{3}[- \.]))?\d{3}[- \.]\d{4}/ This code may seem to be a bit more complicated than usual, but I have 2 phone number fields - one for home phone and one for cell phone. Submitter must enter one but if they enter both they can not be the same number.

Thanks!
User 187934 Photo


Senior Advisor
20,190 posts

Hi paul,
Like this?
https://ericrohloff.com/coffeecup/ccfor … nvert.html
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 91616 Photo


Registered User
27 posts

Appreciate the help, but am totally confused.
Tried to apply what you told me above, but nothing seems to be working as you say it should.
I'm confused about where to place the HTML element. I put it on the form, but in it's place on the preview it is a blank space!
What would I use as place holders for the ZIP Code and phone number fields? Or should there be no place holder?
Ive attached a copy of the file as a ZIPped file.

User 187934 Photo


Senior Advisor
20,190 posts

Try this
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 91616 Photo


Registered User
27 posts

Thanks Eric; that worked.
However, I no longer have the function to ensure that when entering a cell phone, it is not the same as the home phone. You provided me that script, but now I've replaced it with this latest script that requires only entering numbers.

How do I get that previous functionality back and also ensure the submitter only needs to enter numbers?

I've attached the latest project file so you have something to work with.

Thanks again for all your help with this.
User 91616 Photo


Registered User
27 posts

Forgot to mention one thing:
After adding that regexp by creating an HTML element on the screen where you enter the fields, formats, etc, there is an element titled "HTML".

Not a problem, but on the preview it shows as a blank area. Is there a way to hide that do the form is concise?

Thanks.
User 187934 Photo


Senior Advisor
20,190 posts

This should work for the phone number. I didn't see the html but we can address that after we confirm the phone number script.
I can't hear what I'm looking at.
It's easy to overlook something you're not looking for.

This is a site I built for my work.(RSD)
http://esmansgreenhouse.com
This is a site I built for use in my job.(HTML Editor)
https://pestlogbook.com
This is my personal site used for testing and as an easy way to share photos.(RLM imported to RSD)
https://ericrohloff.com
User 91616 Photo


Registered User
27 posts

So far so good.
Just reviewed the form and need to format the ZIP code inputs so the user needs to only input 5 (required) numbers or 9 (without the dash).
Looked on the internet for the input format. When I tried to input the following format (field type of "regexp"), the form says it's invalid:
^[0-9]{5}(?:-[0-9]{4})?$

I also found this (didn't try to use it because it looks to be way off):
^\\b\\d{5}\\b(?:[- ]{1}\\d{4})?$


What is the proper input format?

As for the space caused by the HTML element: It is visible in the "preview". I did a PDF but it fell on the PDF page break. I've attached a ZIP file that includes a screenshot showing the space (immediately above the phone area.


Attachments:
User 91616 Photo


Registered User
27 posts

So far so good.
Just reviewed the form and need to format the ZIP code inputs so the user needs to only input 5 (required) numbers or 9 (without the dash).
Looked on the internet for the input format. When I tried to input the following format (field type of "regexp"), the form says it's invalid:
^[0-9]{5}(?:-[0-9]{4})?$

I also found this (didn't try to use it because it looks to be way off):
^\\b\\d{5}\\b(?:[- ]{1}\\d{4})?$


What is the proper input format?

As for the space caused by the HTML element: It is visible in the "preview". I did a PDF but it fell on the PDF page break. I've attached a ZIP file that includes a screenshot showing the space (immediately above the phone area.


Attachments:

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.