<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>Gravity Support Forums Topic: Website field - not validating without http://</title>
		<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http</link>
		<description>Gravity Support Forums Topic: Website field - not validating without http://</description>
		<language>en-US</language>
		<pubDate>Mon, 13 Apr 2026 14:47:01 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.1</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>https://legacy.forums.gravityhelp.com/search.php</link>
		</textInput>
		<atom:link href="https://legacy.forums.gravityhelp.com/rss/topic/website-field-not-validating-without-http" rel="self" type="application/rss+xml" />

		<item>
			<title>Phil on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-350777</link>
			<pubDate>Fri, 28 Jun 2013 20:53:19 +0000</pubDate>
			<dc:creator>Phil</dc:creator>
			<guid isPermaLink="false">350777@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;&#60;u&#62;UPDATE #2&#60;/u&#62;&#60;br /&#62;
My code above works for a website field, but not for a post custom field whose type is set to website. In the latter case, $field['type'] is 'post_custom_field' instead of 'website'. However, in both cases, $field['inputType'] is 'website', so we can use it instead. Given that $field['inputType'] is not set for all fields (e.g., honeypot), we'll include an isset() check to avoid the php &#34;Notice: Undefined Index&#34;. So...&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;Replace line 8 above (&#60;strike&#62;$types[] = $field['type'];&#60;/strike&#62;) with&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;if ( isset($field[&#38;#39;inputType&#38;#39;]) )
  $types[] = $field[&#38;#39;inputType&#38;#39;];&#60;/code&#62;&#60;/pre&#62;
&#60;/li&#62;
&#60;li&#62;Then replace line 31 above (&#60;strike&#62;if ( 'website' != $field['type'] )&#60;/strike&#62;) with&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;if ( ! isset($field[&#38;#39;inputType&#38;#39;]) &#124;&#124; &#38;#39;website&#38;#39; != $field[&#38;#39;inputType&#38;#39;] )&#60;/code&#62;&#60;/pre&#62;
&#60;/li&#62;
&#60;/ol&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-162137</link>
			<pubDate>Wed, 06 Mar 2013 12:47:37 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">162137@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;@Phil, I fixed the original code.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Phil on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-161102</link>
			<pubDate>Tue, 05 Mar 2013 12:21:39 +0000</pubDate>
			<dc:creator>Phil</dc:creator>
			<guid isPermaLink="false">161102@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;&#60;u&#62;UPDATE&#60;/u&#62;&#60;br /&#62;
A typo In my code above: I returned the wrong variable name on line 13. It should read return $form_tag; instead of &#60;strike&#62;return $content;&#60;/strike&#62;. Otherwise, when a form does not have a website field, the markup for the opening &#60;code&#62;&#38;lt;form&#38;gt;&#60;/code&#62; tag will not be returned/printed and the form will not function.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-160179</link>
			<pubDate>Mon, 04 Mar 2013 15:30:12 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">160179@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thanks for posting that code Phil.  If you would like to add links to those other topic, please feel free to do so.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Phil on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-156934</link>
			<pubDate>Thu, 28 Feb 2013 12:10:43 +0000</pubDate>
			<dc:creator>Phil</dc:creator>
			<guid isPermaLink="false">156934@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Here's a possible workaround. Time will tell if it breaks something. I have only tested on OSX versions of the latest Chrome, Firefox, Safari, and Opera, and not yet on a production site. Note that it probably disables browsers' &#60;a href=&#34;http://diveintohtml5.info/forms.html#validation&#34; rel=&#34;nofollow&#34;&#62;validation of &#60;u&#62;all&#60;/u&#62; HTML5 fields&#60;/a&#62; in the form.&#60;/p&#62;
&#60;ol&#62;
&#60;li&#62;The function my_novalidate() disables browsers' validation of HTML5 fields like input type=&#34;url&#34; fields. Without disabling, I think some browsers (Chrome/Firefox) block the form from even being submitted if &#34;http://&#34;&#34; is missing -- not a Gravity Forms issue, because GF never even receives the data. Opera just adds the http://. Safari doesn't care about missing http://, but then GF will invalidate.&#60;/li&#62;
&#60;li&#62;The function my_protocol() then adds &#34;http://&#34; if the user omitted a protocol. This happens &#60;u&#62;before&#60;/u&#62; the field value makes it to GF's validation procedure.&#60;/li&#62;
&#60;/ol&#62;
&#60;p&#62;Here are my settings for making this work.&#60;/p&#62;
&#60;ul&#62;
&#60;li&#62;GF 1.6+ (I'm on 1.6.12)&#60;/li&#62;
&#60;li&#62;HTML5 enabled everywhere&#60;/li&#62;
&#60;li&#62;Use website field type (instead of text field). This uses input type=&#34;url&#34; (vs. type=&#34;text&#34;), which may have advantages of bringing up &#60;a href=&#34;http://stackoverflow.com/questions/3090369/&#34; rel=&#34;nofollow&#34;&#62;custom keyboards on mobile devices&#60;/a&#62;.&#60;/li&#62;
&#60;li&#62;Don't set up any kind of dynamic population of &#34;http://&#34;&#60;/li&#62;
&#60;/ul&#62;
&#60;p&#62;I hope the code isn't too long here -- &#60;a href=&#34;http://meta.stackoverflow.com/questions/80978/&#34; rel=&#34;nofollow&#34;&#62;some dislike links to code on external sites&#60;/a&#62;.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;// add the &#38;#39;novalidate&#38;#39; setting to &#38;lt;form&#38;gt; tag
// stackoverflow.com/questions/3090369/
function my_novalidate($form_tag, $form) {

  // collect field types
  $types = array();
  foreach ( $form[&#38;#39;fields&#38;#39;] as $field ) {
    $types[] = $field[&#38;#39;type&#38;#39;];
  }

  // bail if form doesn&#38;#39;t have a website field
  if ( ! in_array(&#38;#39;website&#38;#39;, $types) )
    return $form_tag; 

  // add the &#38;#39;novalidate&#38;#39; setting to the website &#38;lt;form&#38;gt; element
  $pattern = &#38;quot;#method=\&#38;#39;post\&#38;#39;#i&#38;quot;;
  $replacement = &#38;quot;method=&#38;#39;post&#38;#39; novalidate&#38;quot;;
  $form_tag = preg_replace($pattern, $replacement, $form_tag);

  return $form_tag;
}
add_filter(&#38;#39;gform_form_tag&#38;#39;,&#38;#39;my_novalidate&#38;#39;,10,2);

// add &#38;quot;http://&#38;quot; to website if protocol omitted
function my_protocol($form) {

  // loop through fields, taking action if website
  foreach ( $form[&#38;#39;fields&#38;#39;] as $field ) {

  // skip if not a website field
  if ( &#38;#39;website&#38;#39; != $field[&#38;#39;type&#38;#39;] )
      continue;

  // retrieve website field value
  $value = RGFormsModel::get_field_value($field);

  // if there is no protocol, add &#38;quot;http://&#38;quot;
  // Recognizes ftp://, ftps://, http://, https://
  // stackoverflow.com/questions/2762061/
  if ( ! empty($value) &#38;amp;&#38;amp; ! preg_match(&#38;quot;~^(?:f&#124;ht)tps?://~i&#38;quot;, $value) ) {
    $value = &#38;quot;http://&#38;quot; . $value;

    // update value in the $_POST array
    $id = (string) $field[&#38;#39;id&#38;#39;];
    $_POST[&#38;#39;input_&#38;#39; . $id] = $value;
  }
  }

  return $form;
}
add_filter(&#38;#39;gform_pre_validation&#38;#39;,&#38;#39;my_protocol&#38;#39;);&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;&#60;u&#62;GF admins:&#60;/u&#62; If the code above is helpful, would it be appropriate to put a link to this post in past related threads &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/website-field&#34; rel=&#34;nofollow&#34;&#62;here&#60;/a&#62; and &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/pre-populating-fields&#34; rel=&#34;nofollow&#34;&#62;here&#60;/a&#62;, for those coming across those posts while looking for ideas on this issue (like I was)? Maybe this is all beyond the scope of the forums.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-65767</link>
			<pubDate>Wed, 11 Jul 2012 10:52:55 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">65767@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I completely understand. Again, you don't have to use the URL field, which would allow you to create your own validation rules, or have no validation rules if you prefer.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gecko_guy on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-65758</link>
			<pubDate>Wed, 11 Jul 2012 10:12:42 +0000</pubDate>
			<dc:creator>gecko_guy</dc:creator>
			<guid isPermaLink="false">65758@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Yes, its what I've done and made it pretty with a bit of CSS, but would have preferred the http:// to simply be hard-coded in to the field. I understand the logic of requiring it as part of the validation process and that it may be needed for more advanced scripts, but if it is required I don't really understand why it has to be re-typed.&#60;/p&#62;
&#60;p&#62;Its not really a problem, just a mild niggle.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>David Peralty on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-65744</link>
			<pubDate>Wed, 11 Jul 2012 09:04:12 +0000</pubDate>
			<dc:creator>David Peralty</dc:creator>
			<guid isPermaLink="false">65744@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You could also add a description to the field that says &#34;http:// required&#34;. It just makes it easily usable by novices in other scripts and whatnot that they need. Rather than having them add that in through PHP later if they want to make a link.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>gecko_guy on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-65701</link>
			<pubDate>Wed, 11 Jul 2012 03:10:40 +0000</pubDate>
			<dc:creator>gecko_guy</dc:creator>
			<guid isPermaLink="false">65701@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Hi, I agree that people will figure it out, but only after they have clicked &#34;submit&#34; and the form fails validation, and causes irritation.&#60;/p&#62;
&#60;p&#62;Is there a functional reason for it to work this way? Does the field have the potential to be used in some special way making the http prefix necessary or to somehow prevent spam? Wouldn't it be better to have the http:// prefix hard-coded if the form requires it?&#60;/p&#62;
&#60;p&#62;Thanks
&#60;/p&#62;</description>
		</item>
		<item>
			<title>kyle on "Website field - not validating without http://"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/website-field-not-validating-without-http#post-57697</link>
			<pubDate>Fri, 04 May 2012 06:04:36 +0000</pubDate>
			<dc:creator>kyle</dc:creator>
			<guid isPermaLink="false">57697@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;You could just use a standard text field, but the URL should have http:// to be valid.  Maybe you can add some help text as a reminder? Ride fans are smart (great band), they'll figure it out!
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
