<?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: File is uploaded before form is validated</title>
		<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated</link>
		<description>Gravity Support Forums Topic: File is uploaded before form is validated</description>
		<language>en-US</language>
		<pubDate>Sun, 19 Apr 2026 23:48:16 +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/file-is-uploaded-before-form-is-validated" rel="self" type="application/rss+xml" />

		<item>
			<title>Quill Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68892</link>
			<pubDate>Wed, 01 Aug 2012 01:02:09 +0000</pubDate>
			<dc:creator>Quill Studios</dc:creator>
			<guid isPermaLink="false">68892@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;OK, its pretty simple to add both the validation and file upload indicator using jquery.validity and Kevin's technique i mentioned.&#60;/p&#62;
&#60;p&#62;Firstly, go ahead and go through the process to add the upload indicator using the guide Kevin made (&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/add-a-file-upload-progress-bar)&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/add-a-file-upload-progress-bar)&#60;/a&#62;.&#60;/p&#62;
&#60;p&#62;Make sure you have it working as it should. Then go download jquery.validity at &#60;a href=&#34;http://validity.thatscaptaintoyou.com&#34; rel=&#34;nofollow&#34;&#62;http://validity.thatscaptaintoyou.com&#60;/a&#62; add the jquery and css files to your page as outlined in my previous post.&#60;/p&#62;
&#60;p&#62;Now, this is where it's a bit different from the previuos example without the uploading indicator. We need to load the start and end methods of validity manually so we can return the result of the validation - we only want to show the upload indicator if the validation found no errors, if it found errors we want nothing to happen until the errors have been fixed by the user. &#60;/p&#62;
&#60;p&#62;Here's the code you need to put in you theme's header.php file, i'll explain it below.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;?php

// jQuery form validation code

if(is_page(&#38;#39;submit&#38;#39;))
{ ?&#38;gt;
	&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;
		jQuery(document).ready(function()
		{
			function validateForm()
			{
			    // Start validation:
    			jQuery.validity.start();

			   	jQuery(&#38;#39;input#input_1_1_3, input#input_1_1_6&#38;#39;)
		        .require(&#38;#39;Please enter your name&#38;#39;);                          

				jQuery(&#38;#39;input#input_1_2, input#input_1_2_2&#38;#39;)
    			.require(&#38;#39;Please enter a valid email address&#38;#39;)
				.match(&#38;#39;email&#38;#39;, &#38;#39;This field must contain a valid email address&#38;#39;)
    			.equal(&#38;#39;Email addresses do not match.&#38;#39;);

				jQuery(&#38;#39;input#input_1_3&#38;#39;)
		        .require(&#38;#39;Please enter your phone number&#38;#39;)
				.match(&#38;#39;number&#38;#39;, &#38;#39;Please enter your phone number&#38;#39;);   

				var result = jQuery.validity.end().valid;

				return result;

        	} // End validity function

		      jQuery(&#38;quot;#gform_wrapper_1&#38;quot;).after(&#38;quot;&#38;lt;div id=&#38;#39;fakeprogress&#38;#39;&#38;gt;&#38;lt;h3&#38;gt;Uploading Files... Please Wait&#38;lt;/h3&#38;gt;&#38;lt;/div&#38;gt;&#38;quot;);
			jQuery(&#38;quot;#fakeprogress&#38;quot;).hide();

			jQuery(&#38;quot;#gform_wrapper_1 .gform_footer input, #gform_wrapper_1 .gform_footer a&#38;quot;).on(&#38;#39;click&#38;#39;, function(e)
			{
				if(validateForm())
				{
					jQuery(&#38;quot;#fakeprogress&#38;quot;).delay(1000).show(&#38;#39;slow&#38;#39;);

				}

				else
				{
					e.preventDefault();
				}

			});

		}); // End document.ready function
	&#38;lt;/script&#38;gt;

&#38;lt;?php
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;OK, so this code just tests to see if we are on the form page &#60;code&#62;if(is_page(&#38;#39;submit)&#60;/code&#62;, then I manually start the validation using&#60;code&#62;jQuery.validity.start();&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;I then define my validation rules, then manually end the validation and get the validation status with &#60;code&#62;jQuery.validity.end().valid;&#60;/code&#62; If there are no errors then &#60;code&#62;jQuery.validity.end().valid&#60;/code&#62; returns TRUE, if there are errors i believe it returns FALSE.&#60;/p&#62;
&#60;p&#62;Then we use the code from Kevin to create and hide the dom elements for the upload indicator.&#60;br /&#62;
&#60;pre&#62;&#60;code&#62;jQuery(&#38;quot;#gform_wrapper_1&#38;quot;).after(&#38;quot;&#38;lt;div id=&#38;#39;fakeprogress&#38;#39;&#38;gt;&#38;lt;h3&#38;gt;Uploading Files... Please Wait&#38;lt;/h3&#38;gt;&#38;lt;/div&#38;gt;&#38;quot;);
jQuery(&#38;quot;#fakeprogress&#38;quot;).hide();&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This next part is where the magic happens, when the submit button is click it tests to see if there were any errors on the form, if not it submits the form and displays the upload indicator - if there were errors it does nothing&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;jQuery(&#38;quot;#gform_wrapper_1 .gform_footer input, #gform_wrapper_1 .gform_footer a&#38;quot;).on(&#38;#39;click&#38;#39;, function(e)
			{
				if(validateForm())
				{
					jQuery(&#38;quot;#fakeprogress&#38;quot;).delay(1000).show(&#38;#39;slow&#38;#39;);

				}

				else
				{
					e.preventDefault();
				}

			});&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This code is customized to my needs, name of the page the form is on will be different for you, as will the validation rules and possibly the element(s) to attach the on click event handler to. &#60;/p&#62;
&#60;p&#62;To find the id's of the form inputs to use in the validation rules use the firebug plugin for firefox, you can just right-click on an element and find it's class and id.&#60;/p&#62;
&#60;p&#62;If you have trouble following or implementing it just let me know and i'll try to help ;)
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68699</link>
			<pubDate>Tue, 31 Jul 2012 02:22:50 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">68699@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Please do post your procedure. I'd like to see how you pulled it off, and others would as well, I'm sure.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Quill Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68495</link>
			<pubDate>Mon, 30 Jul 2012 01:30:05 +0000</pubDate>
			<dc:creator>Quill Studios</dc:creator>
			<guid isPermaLink="false">68495@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;No worries Chris, always keen to help out where i can ;) &#60;/p&#62;
&#60;p&#62;I've also combined the clever jQuery upload progress indicator posted by Kevin Flahaut (&#60;a href=&#34;http://www.gravityhelp.com/forums/topic/add-a-file-upload-progress-bar&#34; rel=&#34;nofollow&#34;&#62;http://www.gravityhelp.com/forums/topic/add-a-file-upload-progress-bar&#60;/a&#62;) with this client side validation, with these two additions file uploads with gravity forms are really pretty user friendly. &#60;/p&#62;
&#60;p&#62;If anyone wants some help implementing these together let me know and i'll post a short description of what i did.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68473</link>
			<pubDate>Sun, 29 Jul 2012 22:34:04 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">68473@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Thank you for posting that.  Looks like a nice solution.  I tested the demo and it works as expected.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Quill Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68470</link>
			<pubDate>Sun, 29 Jul 2012 21:33:26 +0000</pubDate>
			<dc:creator>Quill Studios</dc:creator>
			<guid isPermaLink="false">68470@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;OK, I've implemented some simple client-side form validation to address this problem.&#60;/p&#62;
&#60;p&#62;Go to &#60;a href=&#34;http://validity.thatscaptaintoyou.com/&#34; rel=&#34;nofollow&#34;&#62;http://validity.thatscaptaintoyou.com/&#60;/a&#62; and download the jquery.validity plugin (you could use others, but this is the one i used).&#60;/p&#62;
&#60;p&#62;Add the jquery.validity files to you themes js folder, or whatever folder you are keeping the javascript files in. Include the validity javascript file and css file in your themes header.php file.&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;&#38;lt;link type=&#38;quot;text/css&#38;quot; rel=&#38;quot;Stylesheet&#38;quot; href=&#38;quot;&#38;lt;?php echo get_template_directory_uri() ?&#38;gt;/js/validity/jquery.validity.css&#38;quot; /&#38;gt;

&#38;lt;script type=&#38;quot;text/javascript&#38;quot; src=&#38;quot;&#38;lt;?php echo get_template_directory_uri() ?&#38;gt;/js/validity/jQuery.validity.min.js&#38;quot;&#38;gt;&#38;lt;/script&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Make sure the validity javascript file is included after jQuery has been included.&#60;/p&#62;
&#60;p&#62;Add the following code (you'll need to change it based on your needs and setup, but this should give you a good starting point).&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;[php]
if(is_page(&#38;#39;submit&#38;#39;))
{ ?&#38;gt;
	&#38;lt;script type=&#38;quot;text/javascript&#38;quot;&#38;gt;
		jQuery(document).ready(function()
		{
			jQuery(&#38;#39;form#gform_1&#38;#39;).validity(function()
			{
            	jQuery(&#38;#39;input#input_1_1_3, input#input_1_1_6&#38;#39;)
		        .require(&#38;#39;Please enter your name&#38;#39;);                          

				jQuery(&#38;#39;input#input_1_2, input#input_1_2_2&#38;#39;)
    			.require(&#38;#39;Please enter a valid email address&#38;#39;)
				.match(&#38;#39;email&#38;#39;)
    			.equal(&#38;#39;Email addresses do not match.&#38;#39;);

				jQuery(&#38;#39;input#input_1_3&#38;#39;)
		        .require(&#38;#39;Please enter your phone number&#38;#39;)
				.match(&#38;#39;number&#38;#39;, &#38;#39;Please enter your phone number&#38;#39;);                  

        	}); // End validity function

		}); // End document.ready function
	&#38;lt;/script&#38;gt;
&#38;lt;?php
}
?&#38;gt;&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;This code just tests to see whether the user is on the page with the form, then it loads the validity function, pretty simple. Validity has pretty thorough documentation so if you run into probs check it out. Also, this works best when you aren't using ajax to submit the form.&#60;/p&#62;
&#60;p&#62;You can see the form I've used it on at &#60;a href=&#34;http://www.bimawards.com.au/submit&#34; rel=&#34;nofollow&#34;&#62;http://www.bimawards.com.au/submit&#60;/a&#62; for a demo.&#60;/p&#62;
&#60;p&#62;Hope this helps!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Chris Hajer on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68381</link>
			<pubDate>Sun, 29 Jul 2012 00:19:24 +0000</pubDate>
			<dc:creator>Chris Hajer</dc:creator>
			<guid isPermaLink="false">68381@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I've also worked around that limitation in the past by having the file upload on another form, after the initial information is validated.  Submit form 1 with all the relevant information, then, if you are accepting large files, redirect the visitor to the second form which has the upload functionality.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Quill Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-68376</link>
			<pubDate>Sat, 28 Jul 2012 22:52:54 +0000</pubDate>
			<dc:creator>Quill Studios</dc:creator>
			<guid isPermaLink="false">68376@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;I see what Carl is saying, here, but you can validate before the upload is performed, i don't know why he being so stubborn on this point. Its ridiculous is say that users should wait until a file is uploaded, which in my case is up to 20-30 minutes, before they are told they had a typo in their email address. &#60;/p&#62;
&#60;p&#62;I'm planning on implementing some seperate jQuery validation to pick up any errors in the form BEFORE the request is sent to the server. It's very simple and should be an easy fix to this prob, I'll do it tomorrow and re-post to tell others how it can be done.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>MPC Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-23394</link>
			<pubDate>Fri, 15 Apr 2011 13:00:17 +0000</pubDate>
			<dc:creator>MPC Studios</dc:creator>
			<guid isPermaLink="false">23394@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Strange, though, that it seems to show the error immediately when I leave the first field empty.&#60;/p&#62;
&#60;p&#62;...and of course, now that I go to try it again so I can take a screenshot to show you, it isn't doing it anymore. May have been a browser issue those few times, I suppose.&#60;/p&#62;
&#60;p&#62;I guess there isn't much that can be done, then. I very much appreciate your patience with me.&#60;/p&#62;
&#60;p&#62;I have found the forum post outlining &#60;a href=&#34;http://www.gravityhelp.com/forums/topic/add-a-file-upload-progress-bar#post-6584&#34; rel=&#34;nofollow&#34;&#62;how to add a pseudo progress bar for file uploads&#60;/a&#62; (which I'm thinking will help alleviate possible confusion), and implemented it successfully (though it's commented out right now). Do you know if it's possible to have it disappear when validation errors come up? Or should I ask this in a new thread?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Carl Hancock on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-23390</link>
			<pubDate>Fri, 15 Apr 2011 12:49:49 +0000</pubDate>
			<dc:creator>Carl Hancock</dc:creator>
			<guid isPermaLink="false">23390@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;There isn't anyway around that.  The upload is part of the form submit action.  The form isn't fully submitted until the upload is complete.  That is how form submit actions work if they have file upload fields.  &#60;/p&#62;
&#60;p&#62;The validation is also done when the form is submitted, so it doesn't know there is errors until the form is submitted and by extension the form isn't completely submitted until file uploads on the form have been completed and the form action is complete.&#60;/p&#62;
&#60;p&#62;Validation isn't done client side, it's done server side to prevent field tampering.  If it was done purely client side with javascript you could do validation before a form is submitted, but that isn't how it works.
&#60;/p&#62;</description>
		</item>
		<item>
			<title>MPC Studios on "File is uploaded before form is validated"</title>
			<link>https://legacy.forums.gravityhelp.com/topic/file-is-uploaded-before-form-is-validated#post-23388</link>
			<pubDate>Fri, 15 Apr 2011 12:45:43 +0000</pubDate>
			<dc:creator>MPC Studios</dc:creator>
			<guid isPermaLink="false">23388@https://legacy.forums.gravityhelp.com/</guid>
			<description>&#60;p&#62;Understand, I don't care if the file is uploaded during validation; that's fine. The problem I have is that it waits until the upload is completely finished before telling me there's an error in the form, and for some people, that can be several minutes. From what you describe as expected behavior, and from what I've seen when I leave the first field empty, validation errors should show up almost immediately (or at least within a few seconds), not several minutes after the user has hit the submit button.
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
