0

We have a form where user enters their firstName, lastName and address. But some users are entering their firstName/lastName as website.

Ex: www.google.com, google.com or some other spam site.

Is there a way to validate these kind of inputs?

Note : We don't want to replace or avoid special characters as it is causing issues when people enter their name in a different language other than English.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
krishna_5c3
  • 509
  • 6
  • 14

1 Answers1

1

Those "some users" are likely hackers who are likely penetration testing your web site.

Use a regular expression to filter out fake names that match some pattern. Does the name start with HTTP:// or WWW.? Does the name end in .com or .net? If so, don't allow users to enter that name.

If you Google "regular expression for URL matching", you should get plenty of examples of regular expressions that will match URL strings. Then all you need to do for validation is not allow names that match the URL regex, and conversely, allow names that don't match.

geneSummons
  • 907
  • 5
  • 15
  • Thanks @geneSummons. I think this will work https://stackoverflow.com/questions/2385701/regular-expression-for-first-and-last-name – krishna_5c3 Sep 12 '17 at 17:28