Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Unless I've missed something, there is no existing way to check a value entered is a valid URL.
This patch provides a simple test to see if a textfield contains a valid URL using the core valid_url
function.
Comment | File | Size | Author |
---|---|---|---|
#9 | webform_validation-valid_url-982468-9.patch | 655 bytes | theunraveler |
#7 | webform_validation_982468_valid_url.patch | 1.38 KB | Liam Morland |
#3 | 982468_valid_url_validation_d6.patch | 1.12 KB | svendecabooter |
#3 | 982468_valid_url_validation_d7.patch | 1.11 KB | svendecabooter |
webform_validation.valid_url.patch | 1.51 KB | nicholasThompson | |
Comments
Comment #1
nicholasThompsonbtw, This patch was made against HEAD.
Comment #2
svendecabooterHi Nicholas,
Thanks for your patch! Sorry for the late feedback.
Wouldn't it be better though to use
valid_url($val, TRUE)
, as it seems like a more widely used use case to validate external URLs...I'm not sure how the regex without $absolute = TRUE works, but it validates practically everything when i test it (including one word text entries).
Do you have a specific use case in mind where $absolute would have to be FALSE?
Comment #3
svendecabooterUpdated patches in attachment, using $absolute = TRUE.
I'll have to figure out what the consequences of all of this are at some point.
Comment #4
svendecabooterComment #5
jibranAccording to patch and http://drupal.org/node/822146#comment-3080360 I put this in my module and it works fine for me,
Comment #6
Liam MorlandComment #7
Liam MorlandFixed in 1d058b3.
Comment #8
Liam MorlandComment #9
theunraveler CreditAttribution: theunraveler commentedI think it is probably best not to include links to Drupal's API documentation in user-facing help text. The end user does not really care which of Drupal's API functions is used to validate the URL, and including a link to developer-oriented documentation is just confusing. Here's a patch against the latest 7.x-1.x that removes this part from the help text.
Aside from that, this looks good.
Comment #10
Liam MorlandComment #11
Liam Morlandhttp://drupalcode.org/project/webform_validation.git/commitdiff/6ff2de1
Comment #12
Liam MorlandComment #13
Liam MorlandThanks, theunraveler.
Comment #14
Liam MorlandDrupal 6 is no longer supported.