[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

How to check for valid text input?

Can someone help me with a Perl code to check for:

1. Valid text input (e.g. a person's name)

2. Valid text and numbers input (e.g an address)

I would like to use this in my form-processor. Thanks!
0
zgee
Asked:
zgee
1 Solution
 
ozoCommented:
1. a person's name may have numbers
2. an address may have no numbers

Unless the address is known to be in a specific area with specific rules for what is valis and what is not,
I don't see how you could check this in any language.
0
 
mitekCommented:
of course, it can be checked, and in any language
one way to do that in perl would be:

if ($name =~ /^[\w\'- ]+$/) {
  # valid name. it contains only letters, spaces, dashes and quotes (like, o'donnel)
}

if ($address =~ /^[\w\d\'\"- ]+$/) {
  # valid address. it contains letters, digits, spaces, dashes, single and double quotes
}

0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now