<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1037313" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1037313</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/whats-best-way-validate-form#comment-1214080</link>
    <description> &lt;p&gt;In all honesty, I know very little about Javascript. I can&#039;t help you much with that. &lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://uk.php.net/strlen&quot; class=&quot;bb-url&quot;&gt;strlen()&lt;/a&gt; returns the length of a string. If you ever want to know what a php function does just go to php.net/functionname and you&#039;ll get a nice description, examples of usage and lots of comments!&lt;/p&gt;
 </description>
     <pubDate>Fri, 26 Jan 2007 16:42:39 +0000</pubDate>
 <dc:creator>andy206uk</dc:creator>
 <guid isPermaLink="false">comment 1214080 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/whats-best-way-validate-form#comment-1214075</link>
    <description> &lt;p&gt;Another question: I&#039;m using some javascript to show immediate feedback. How do I use event handlers without putting them into the HTML? So instead of:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&amp;lt;input type=&amp;#039;text&amp;#039; size=&amp;#039;30&amp;#039; name=&amp;#039;name&amp;#039; id=&amp;#039;name&amp;#039; value=&amp;quot;&amp;quot;&lt;br /&gt; maxlength=&amp;#039;255&amp;#039; onblur=&amp;quot;validate(&amp;#039;name&amp;#039;);&amp;quot; /&amp;gt;&lt;/code&gt;&lt;/div&gt;&#039;&lt;/p&gt;
&lt;p&gt;I should have no onFocus in the link and have something like this in my javascript instead:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;document.getElementById(&amp;quot;name&amp;quot;).onblur = validate(&amp;#039;name&amp;#039;);&lt;/code&gt;&#039;&lt;/p&gt;
&lt;p&gt;But that doesn&#039;t work at all. This is the best way to do it, right? I&#039;ve seen people talk about avoiding event handlers in HTML but I can&#039;t find out how to make it work.&lt;/p&gt;
 </description>
     <pubDate>Fri, 26 Jan 2007 15:44:52 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1214075 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/whats-best-way-validate-form#comment-1214072</link>
    <description> &lt;p&gt;Okay, that&#039;s almost understandable! What does [incode]strlen[/incode] mean?&lt;/p&gt;
&lt;p&gt;I think I might do some javascript for immediate feedback and then validate using php after the form is submitted.&lt;/p&gt;
 </description>
     <pubDate>Fri, 26 Jan 2007 14:08:46 +0000</pubDate>
 <dc:creator>Megan</dc:creator>
 <guid isPermaLink="false">comment 1214072 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/html-css-and-javascript/whats-best-way-validate-form#comment-1214053</link>
    <description> &lt;blockquote class=&quot;bb-quote-body&quot;&gt;&lt;p&gt;&lt;strong&gt;Megan;214050 wrote:&lt;/strong&gt; Do I do it all through javascript? How do I display the instructions to the user? Can I do this without event handlers in the HTML part?&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;That&#039;s a matter of choice... usually I just check the fields using PHP as you can&#039;t rely on JS being on all for all users.&lt;/p&gt;
&lt;p&gt;Basically you just need to check that the details being posted match what you want/expect.&lt;/p&gt;
&lt;p&gt;For instance if you want to ensure a field is a certain size you would do:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;strlen&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: #0000BB&quot;&gt;varname&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;]) &amp;lt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;5 &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;|| &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;strlen&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: #0000BB&quot;&gt;varname&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;])&amp;nbsp; &amp;gt; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;10&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) { &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$error &lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;.= \&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;Varname should be between 5 and 10 characters long&amp;lt;br /&amp;gt;\&quot;; &lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Then repeat it for each variable. once you&#039;ve validated all of the vars do:&lt;/p&gt;
&lt;p&gt;&lt;div class=&quot;codeblock&quot;&gt;&lt;code&gt;&lt;span style=&quot;color: #000000&quot;&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;&amp;lt;?php&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;if(&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$error&lt;/span&gt;&lt;span style=&quot;color: #007700&quot;&gt;) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; echo(\&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&quot;&amp;lt;p&amp;gt;&lt;/span&gt;&lt;span style=&quot;color: #0000BB&quot;&gt;$error&lt;/span&gt;&lt;span style=&quot;color: #DD0000&quot;&gt;&amp;lt;/p&amp;gt;\&quot;);&lt;br /&gt;} else {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; //**** process the form (ie mailto, stick it in a db etc *****&lt;br /&gt;}&lt;br /&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/div&gt;&lt;/p&gt;
&lt;p&gt;Obviously, this is a really simple example. You can make it more complicated in various ways (for instance, I add all of the errors to an array with the key as the variable name - then I can highlight the problem fields!).&lt;/p&gt;
 </description>
     <pubDate>Thu, 25 Jan 2007 21:29:44 +0000</pubDate>
 <dc:creator>andy206uk</dc:creator>
 <guid isPermaLink="false">comment 1214053 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
