joe_john Posted April 28, 2014 Share Posted April 28, 2014 This is kind of related to the question from yesterday, on how to block urls in the phone number field I was given this code: /^([\d\.()\:\- ]+)(ext(ension)?:\s+\d+)?$/i which is good, but it's not liberal enough. I looked at past submissions, and people are entering some weird things. for example, instead of extension, they entered @ext which would get rejected if I implement the above code. my goal is to be as liberal as possible, so I think instead of allowing certain characters and disallowing everything else, I should allow everything and disallow just certain characters I want to block http // www .com .net .info .org if someone puts any of these strings in the phone number field and presses submit, the form should not get submitted. Can I do this? Link to comment https://forums.phpfreaks.com/topic/288097-block-certain-words-using-validation-regex/ Share on other sites More sharing options...
requinix Posted April 28, 2014 Share Posted April 28, 2014 Except for the extensions, the basic rule would be "digits, symbols, and spaces", right? Then the extension might have "e" or "ext" or "extension" or whatever, followed by more numbers. ^[\d.-() ]+([extension]+\d+)$Doesn't allow slashes, doesn't allow letters not found in the word "extension" and even those have to be followed by just digits. Link to comment https://forums.phpfreaks.com/topic/288097-block-certain-words-using-validation-regex/#findComment-1477561 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.