<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1044345" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1044345</link>
    <description></description>
    <language>en</language>
          <item>
    <title>Here is the general rundown</title>
    <link>https://www.webmaster-forums.net/web-programming-and-application-development/asp-form-validation#comment-1243258</link>
    <description> &lt;p&gt;Here is the general rundown of how I do a form, I&#039;ll give the &quot;basic&quot; process of how I set the script up in PHP, and you should be able to follow over to ASP (ie. get rid of $ in front of variable names LOL)&lt;/p&gt;
&lt;p&gt;- Create an array, say $aryErr. This will contain a list of error messages to display&lt;/p&gt;
&lt;p&gt;- Check for post values, if so, then start the validation process.&lt;/p&gt;
&lt;p&gt;--- For each item you check, instead of setting a main bool value of true or false like you are doing, we add an element to the array with the message. Again, you&#039;ll have to convert the idea over to ASP:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (strlen($_POST[&amp;#039;Username&amp;#039;]) &amp;lt; 3) $aryErr[&amp;#039;UserName&amp;#039;] = &amp;quot;Username must be at least 3 characters&amp;quot;;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;--- At the end of all validation, while still inside the &quot;if there are post values&quot;. we check how many elements $aryErr has, if it is none, then all validated, and now we process the form.&lt;/p&gt;
&lt;p&gt;-- Now for the &quot;ELSE&quot; side of if there were post values (form submitted).&lt;/p&gt;
&lt;p&gt;--- Set all &quot;Post&quot; variables to their default values. (usually, most are empty strings) You should do this here, as down in the form you will be displaying the these variables as the Value=&quot;&quot; in the inputs&lt;/p&gt;
&lt;p&gt;- Ok, at this point the post variables from the form should either contain what they submitted, or the default values for first time processing.&lt;/p&gt;
&lt;p&gt;- Display the main code for the page up till where the &quot;guts&quot; of the form go.&lt;/p&gt;
&lt;p&gt;-- IF there are post values, and count of aryError is zero, form was submitted, so show your &quot;thank you&quot; message&lt;/p&gt;
&lt;p&gt;-- ELSE display the form for them to fill out since it is the first time or they entered something wrong&lt;/p&gt;
&lt;p&gt;--- IF count of aryErrors is at least one, display a block letting them know they have errors, and loop through he array displaying each message&lt;/p&gt;
&lt;p&gt;-- In each form input, do something like the following. Make sure you find an ASP equivilant to the htmlspecialchar() I use. Very important.&lt;br /&gt;
&lt;code&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;UserName&amp;quot; value=&amp;quot;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;echo &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;htmlspecialchar&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$_POST&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&#039;UserName&#039;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]); &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&amp;quot; &amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;- close up the page with the rest fo the code.&lt;/p&gt;
 </description>
     <pubDate>Tue, 07 Jul 2009 13:31:44 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1243258 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
