Correct way of using the us phone number field with a country selector

Kentico User asked on May 26, 2016 22:21

Hi,

If I have a field of type country selector and a field of type us phone number. If a country other than U.S is selected than the us phone number field is not changed in any way. How would one solve this U.I issue?

Or do you not use a us phone number field with a country selector in a form?

Thank you,

Correct Answer

Brenden Kehren answered on May 26, 2016 22:39

I never use the US Phone control because it puts 3 textboxes and labels on the page. You can easily add some class to a plain textbox control to add some jquery validation to it if you want.

Another option is to create your own form controls which is pretty easy really and typically allows for your exact specification. I do this when a client has a lot of forms and has oddities about every one.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Chetan Sharma answered on May 27, 2016 13:53 (last edited on May 27, 2016 13:53)

HI,

By using "pattern" attribute inside an input tag you can do validation without writing any code. You will need to write a regex inside a pattern attribute to support this. This came with HTML5

YOu can check these examples for reference

Working with HTML5 pattern attribute

On the other side, as Brenden said, I would also avoid that.

Regards Chetan

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.