Jump to content

Website validation


This topic is 5404 days old. Please don't post here. Open a new topic instead.

Recommended Posts

My client's users are entering invalid website URL's into a FMP field. I'd like a custom function which will at least test whether the URL is well formed, start with either http:// or https:// and end with a valid .com or similar.

I've checked Brian Dunning's site and haven't found what I'm looking for. Any ideas?

With appreciation

Link to comment
Share on other sites

Here is a list of common TLD http://en.wikipedia.org/wiki/List_of_Internet_top-level_domains

A pattern count to grab the last few characters match a this list of TLD

in addition to the starting characters should be pretty easy to validate.

But some websites end in .com.au for example. So that would have to be considered as well.

Link to comment
Share on other sites

Is internet available where data is being input? If so, you may want to try fetching the header to the page only (not content); this should be quite fast. It appears you're on Mac, in which case this could be achieve with shell command cURL.

i.e. curl http://www.google.com --head --output outputfile

I'm running on a PC, but cURL is free for it and works equally well. The first line of the cURL results will show status: e.g. HTTP/1.1 200 OK or anything else for can't load (e.g. first line reads HTTP/1.1 403 Forbidden) or cURL may return could not resolve host. If the cURL output is appended to a file, it could be processed later by Filemaker, or Filemaker could just wait until the cURL output file exists, then re-import it.

There are a good deal of URL validators in PHP, javascript, etc on the web which can be altered to work within FM's webviewer. e.g. in address line of your web browser, enter:

javascript:var regexp = /(ftp|http|https):(w+:{0,1}w*@)?(S+)(:[0-9]+)?(/|/([w#!:.?+=&%@!-/]))?/;document.content=regexp.test("http://www.google.com");

(above validates https://www.google.com) -- it returns 'true' or 'false'. This function can be used in FM using webviewer allowing a regular expression match without a plugin (webviewer contents can then be read back into a field) or it can be translated into an FM custom function.

This isn't as definitive as going out to fetch page of course. Webviewer can also be used to load page; it can even get headers only with HTTP requests.

Link to comment
Share on other sites

This topic is 5404 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.