Page 1 of 1

From fields - Can I mandate a format for phone and SS# ?

Posted: Fri Feb 07, 2014 10:38 pm
by earcandy
Is it possible in my html form to require that phone numbers be entered as ###-###-#### and SS#'s as ###-##-#### ?

I am fairly new to this and figured out how to use required and placeholder but neither demands the user enter these two fields in these formats.

Appreciate any help.

Code: Select all

Home Ph:<strong> <input name="HomePhone" type="text" placeholder="XXX-XXX-XXXX" required/>

Social Security Number:&nbsp;&nbsp;
	<input name="SocialSecurity" type="text" placeholder="XXX-XX-XXXX" />

Re: From fields - Can I mandate a format for phone and SS# ?

Posted: Sat Feb 08, 2014 1:14 am
by JohnnyB
The best way to do it is using Javascript.
There is a jQuery plugin called "maskit" that I've used successfully in the past. There are other similar ones too.

Re: From fields - Can I mandate a format for phone and SS# ?

Posted: Sat Feb 08, 2014 5:40 pm
by velden
I think you should also consider doing some SERVER side validation if you want to be sure valid information is entered.

jQuery is client side scripting. Client (side) input should never be trusted. Maybe it's not that important in this case.

If you're using Form Builder for this form: it has possibility to do some regex checks on submitted fields.

Re: From fields - Can I mandate a format for phone and SS# ?

Posted: Sun Feb 09, 2014 1:01 am
by paulbaker
Remember, too, that depending on your application you need to consider phone number formats worldwide - the format you give would be no good for UK numbers, for example.