Self Improvement Articles Directory - Infrared Sauna - Internet Advertising - Debt Consolidation - WoW Gold

PDA

View Full Version : Help with some Regex


getwiththeprogram
Apr 9th 2007, 1:22 pm
Hi,

I am looking at updating a site for someone and they have asked for some tweaks which are new to me, from having a look online it seems I need or its best to use serveral regex's to check prior to a form submission but I cant find a easy to follow tutorial which I could adapt.

Any help or links to guides to follow please :confused:

1) first letter of a field must be a letter anything after is allowed
2) zip code in format of AB12 AB13 or AB1 AB1 must be uppercase
3) phone number in 12345 111111 or 1234 1234
4) email address something@something.com (lowercase and check for @)
5) credit card to be 1234 1234 1234 1234

Thanks to anyone for taking the time to read my post.

nico_swd
Apr 9th 2007, 1:39 pm
Validating the input on the client's side seems rather pointless to me, because the user can just disable JavaScript and submit the form like he wants to. The input should always be validated on the server-side.

If you want to do an additional pre-check, that's fine. But a waste of time, if you ask me.

getwiththeprogram
Apr 9th 2007, 1:44 pm
Yes I agree, and I will again make a point to him of saying they should move to a server side validation, but client side pre checks are ok as well.
Bit out of my depth I have done simplish javascript before to check if form fields are blank but this uppercase and formatting stuff seems to be quite intense.

getwiththeprogram
Apr 12th 2007, 8:32 am
Any pointers? The guides I have seem to just confuse me further, and I cant seem to find anything to help me test/try out variations.