dahui Posted September 17, 2005 Posted September 17, 2005 my english is limited and I am quite sure to find awnsers here but all my seraches result into 0 results I want to know how to check thecontent offromfield for concitencies like phonenumbers has no other than 1234567890 () +. / I searched for many combinations of form formfield inputfield validate verify verifcation check . . . :blink: :blush: :huh: please point me in right direction thx dahui
dahui Posted September 17, 2005 Author Posted September 17, 2005 NOBODY ??? <_< don't you care if someone e.g. enters "sh21fg132sdhgd1" as phone-number ??? dahui
Guest Posted September 17, 2005 Posted September 17, 2005 hello mike try the ereg like this if (ereg ("[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]", $tel_number) != 1 ) { // invalid number } but you need to handle the other cases with area code,-, etc. (This is for 10 digit numbers)
AlanR Posted September 17, 2005 Posted September 17, 2005 NOBODY ??? <_< don't you care if someone e.g. enters "sh21fg132sdhgd1" as phone-number ??? dahui <{POST_SNAPBACK}> In the U.S. that could be a valid number. :P Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)
dahui Posted September 18, 2005 Author Posted September 18, 2005 In the U.S. that could be a valid number. :P <{POST_SNAPBACK}> you mean a vanity number like that :D btw we got the in good OLD europe to dahui
dahui Posted September 18, 2005 Author Posted September 18, 2005 hello mike try the ereg like this if (ereg ("[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]", $tel_number) != 1 ) { // invalid number } but you need to handle the other cases with area code,-, etc. (This is for 10 digit numbers) <{POST_SNAPBACK}> hi mark thy for yr input if I do unerstand I can use this ereg (is it a function?) for all the inputfileds to be validated? some more qusetions arise ;) when I define like you did explain, would that mean a 9 digit number would be invalid? and a lot more, so the master question where can i find more informaion on howto use ereg? thx dahui search ereg on broad bings 390 ++ with :blush:
AlanR Posted September 18, 2005 Posted September 18, 2005 where can i find more informaion on howto use ereg? thx dahui <{POST_SNAPBACK}> http://us2.php.net/manual/en/function.ereg.php Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)
dahui Posted September 18, 2005 Author Posted September 18, 2005 http://us2.php.net/manual/en/function.ereg.php <{POST_SNAPBACK}> thx found the german version as well I was looking for some more examples as this is hard for me to make a pefect match dahui
dahui Posted September 18, 2005 Author Posted September 18, 2005 ok, a bit further in my knowledge but not satisfied yet ;) e.g. (ereg ("([0-9]{5})/([0-9]{12})", $tel_number) != 1 ) { // invalid number } would that validate any fone as valid if [prefix 1-5 digits long consisting only of 0-9]/[number 1-12 digits long consisting only of 0-9] ??? like 1/123456789012 12345/1 but what is whith extensions like 1234/123456789-78 they will be errored, right? further I found in the above link e.g. this if (ereg("[^[:space:]a-zA-Z0-9_.-\\']", $string)) to validate a Name, but I cannot read it any process rather than implement and trial and error for ereg's to be checked? or even more basic: how do you folks out there handle this on your live carts, or do I have a completely wring appoach to this issue? dahui
Guest Posted September 18, 2005 Posted September 18, 2005 mike you can place a hyphen for optional digits like extension etc like if(ereg("^[0-9]{10}(-[0-9]{4})$",$tel_number) != 1 { // Invalid number } so this will require 10 digit number and 4 digit optional extension with a - in between for real names use the a-zA-Z latin characters validatio check.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.