0

I see only e-mail and textfield, but no URL.

How can I add to my form URL field with the validation rules for URL? e.g.

http://somesite.com

or

somesite.com

or

www.somesite.com

?

2 Answers 2

2

Well if you have tons of time you could implement a component type... but because that is unlikely you should just add a validation hook and a textfield to the webform. You could do a valid_url($form_state['values'][[your_field_name']); in your validation hook.

Someone asked this question on d.o previously here. You can find all sorts of examples on "things you may need to do special with a webform" here.

Another possible solution would be to install the Webform Validation module, add a regex validation to your field, and steal a known usable url validation regex like drupal has.

3
  • Any idea why this is not one of the default options (textfield, e-mail, date...) in the list of Webform option for fields? I mean you need to add URl in a form a lot of times. The question like e.g. "What is your website URL?" seems to be in the forms imho often. Or?
    – Derfder
    Dec 6, 2012 at 21:46
  • Because someone hasn't implemented a webform link component, or you and myself cannot find one. See here drupal.org/node/1660144 Dec 6, 2012 at 21:49
  • Anyway thanks, I will try webform validation and let you know if it works.
    – Derfder
    Dec 6, 2012 at 21:49
2

There is a module called webform_link that could also help you.

This module verifies that a valid URL is entered and displays the result as a link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.