Anyone know of a module that can check the base path of the URL to ensure the user is entering the correct URL?

I.e. the field is asking for the Facebook URL but they put in a Twitter one.

So should the user enter a different URL they won’t be able to continue unless the link contains www.facebook.com/.


Not a module, but you can add a custom validator that parses the string that the user put in for URL to see whether it contains the expected strings, e.g.

if (strpos($url, 'facebook.com') === 0) { ... }

Note the triple-equals is necessary with strpos because otherwise "found at position zero" (return value of 0) is falsey, and so is "not found" (no return value).


Solved it by using regular expressions.

Attaching sources:

https://drupal.org/project/field_validation http://m.youtube.com/watch?v=hE87Z2sOtfs

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy