Validating US phone number with php/regex

后端 未结 5 549
误落风尘
误落风尘 2020-11-30 08:11

EDIT: I\'ve mixed and modified two of the answers given below to form the full function which now does what I had wanted and then some... So I figured I

5条回答
  •  [愿得一人]
    2020-11-30 08:29

    Alternatively, you could use some pretty simple and straightforward JavaScript to force the user to enter in a much more specified format. The Masked Input Plugin ( http://digitalbush.com/projects/masked-input-plugin/ ) for jQuery allows you to mask an HTML input as a telephone number, only allowing the person to enter a number in the format xxx-xxx-xxxx. It doesn't solve your extension issues, but it does provide for a much cleaner user experience.

提交回复
热议问题